Log in

View Full Version : MYSQL change user id manually


FrozenCreations
08-24-2005, 12:38 AM
heyo, i was wandering threw my vast vast vast database looking at the user table, i went in, clicked on browse,

now, user #1 is obously the person who installed vb... and i need to change his userid form 1 to my user id (4). i tryed doing that in my spot, but when i did, all that happened was my username was changed to user#1's name :) if that makes any sence...

if not, ill try 2 explain it a bit more


basiclly i need 2 change the userids :)

Guest190829
08-24-2005, 12:53 AM
UPDATE user
SET userid = '1'
WHERE userid = '4';

UPDATE user
SET userid = '4'
WHERE userid = '1' AND username= 'username';

The above two queries should work, I didn't test them. And I also don't know how this will affect your board. So be warned, and I would test it on a test board before you do it.

And Change 'username' with the username of the user you want to switch.

FrozenCreations
08-24-2005, 12:57 AM
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table user
SET userid = '1'
WHERE userid = '2'' at line 1

Guest190829
08-24-2005, 12:59 AM
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table user
SET userid = '1'
WHERE userid = '2'' at line 1

You used a double quote instead of a single quote in your where clause.

FrozenCreations
08-24-2005, 01:02 AM
lol, whoops, and i thought i copyed it /;

SQL-query :

UPDATE user SET userid = '1' WHERE userid = '4'

MySQL said:

#1062 - Duplicate entry '1' for key 1

and shouldent i have the username 4 teh first 1 aswell?

Guest190829
08-24-2005, 01:05 AM
The username isn't needed for the first one since there are not duplicate user-ids. For the second one however, you do need it to prevent the error your getting know.

FrozenCreations
08-24-2005, 01:07 AM
lol, and how would i fix it?

do i out them both in?

im only putting in the first 1

should i do both?

and what username do i put in? mine or the other 1?

Guest190829
08-24-2005, 01:15 AM
Hm...it seems the userid field must be unique. You can try first setting the user with userid 1 to have a userid that doesn't exist, then change yours to userid 1, and then change his to 4. But I don't know what effect this would have on the database and the auto_increment. Why do you need to this anyway?

FrozenCreations
08-24-2005, 01:18 AM
i just to be #1 thats all ;) i was on our old site... but he installed vb, (and is nolonger active)

and doing that... wouldent that change all the users posts... llike swttch em around?

al user 1's posts becoume user #4 posts... so on?

Guest190829
08-24-2005, 01:20 AM
i just to be #1 thats all ;) i was on our old site... but he installed vb, (and is nolonger active)

and doing that... wouldent that change all the users posts... llike swttch em around?

al user 1's posts becoume user #4 posts... so on?

Not sure, that's why I'm so iffy on doing it. I don't know the side-effects. If I were you, I'd leave myself as 4.

FrozenCreations
08-24-2005, 01:25 AM
if someone would make a hack of this...! i would love em 2 no extent!

(i added you 2 icq... :))

Andreas
08-24-2005, 01:40 AM
Sorry, but what the Hell are you guys trying to do?

If you really want to change the Userids you will need a whole bunch of queries.
(Really not worth it)

FrozenCreations
08-24-2005, 01:48 AM
well, still, i would like to have it done!

and im trying 2 change the userids...

1>4
1<4

Marco van Herwaarden
08-24-2005, 05:19 AM
Maybe too late but....DON'T EVEN TRY THIS!!!!!!!!!

Guest190829
08-24-2005, 06:00 AM
:ermm: Hopefully he listened my warning that I didn't really know what could happen!

Andreas
08-24-2005, 08:31 AM
Maybe too late but....DON'T EVEN TRY THIS!!!!!!!!!
At least not if you don't know exactly what you are doing ... it's a hell of a job to do.

FrozenCreations
08-24-2005, 11:48 AM
i have my own bacup server ;) dont worrie.. i test all my crap on that b4 i do it 4 real :)

y? what could it have done?

Marco van Herwaarden
08-24-2005, 12:18 PM
The userid is referenced in a dozen tables (and even on some places where it is not just a column called 'userid'), and all would need to be changed at once without any conflicts.

Furthermore changing the userid serves no purpose at all it is just an internal number.

I would say that the chance that you F... Up is about 99%.

Andreas
08-24-2005, 12:21 PM
Purpose = It's better for his Ego being Userid #1 ;)

FrozenCreations
08-24-2005, 12:25 PM
yup, kerby got it :) and besides.. i the head admin.. and when i go to other sites.. i usually go 2 userid #1 ;), thats all :D

Marco van Herwaarden
08-24-2005, 12:32 PM
Then some non-head Admin should cut your head off, for considering risking the board for your own ego.

PS The line above is a joke, but holds some truth in it.

Edit: Added the word 'considering'

FrozenCreations
08-24-2005, 12:35 PM
no, i dident do it on MY fourm... i have a backup.. on my harddrive :)

and, just 4 the record.. nothign screwed up on that1... and i changed a ton of crap in teh mysql ;)

Marco van Herwaarden
08-24-2005, 01:34 PM
no, i dident do it on MY fourm... i have a backup.. on my harddrive :)

and, just 4 the record.. nothign screwed up on that1... and i changed a ton of crap in teh mysql ;)Just edited my previous post.

FrozenCreations
08-24-2005, 10:50 PM
thankyou ;)