MyBB Community Forums

Full Version: Need to restore hard deleted account
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

An account was deleted that was important. Is there anyway that I can trick MySQL so as I can insert a new record into the database with a user id of 10 without it auto incrementing? If I use phpmyadmin and just insert and change the userid to 10, will that fix the issue? I can insert the same username and everything else then just do a recount?

Thanks,
Mike
I did something similar and deleted a member's account by accident. Thankfully bubulang saved me with these instructions (for when said member signed up with a new id):

Original post link:

(2010-08-07, 02:47 PM)bubulang Wrote: [ -> ]That would be possible as well. Run this query at your phpmyadmin

UPDATE mybb_posts SET uid = x WHERE username = 'deleted_user_username';

Replace x with the user id of the new registered user whom you want to attribute the posts of the deleted user and replace deleted_user_username with the username that your deleted user used to have before he deleted his account.

It will work. As it happens, I did it only yesterday at my own forum too for a couple of deleted users who came back.

If you want to restore back the deleted threads too, run this query

UPDATE mybb_threads SET uid = x WHERE username = 'deleted_user_username';

And replace accordingly the values as explained above. Also if your db tables use another prefix other than the default mybb_ then you should use that instead when running the queries.

Then go to your Admin Panel->Tools & Maintenance->Recount & Rebuild and run the first 4 options there.

Hopefully this will be helpful for you too Smile
So, I can never restore user id 10?

Thanks for this btw.
Whew, I did it. Thanks a lot, it was easier than I thought.

Very much appreciated there lad, I am grateful,
Mike
(2010-08-16, 01:00 AM)Audentio Wrote: [ -> ]Whew, I did it. Thanks a lot, it was easier than I thought.

Very much appreciated there lad, I am grateful,
Mike

I'm not aware of any issues that would arise from manually editing the UID, provided the rest of the data in that record was sound (which it should be if you copied the data straight from a backup). So, what you did should be fine Smile
Yeah, and I fixed the auto_increment. I always thought that mysql stored auto_increment so that way no matter what you can only use it once. It was as easy as registering a new user with the same username then changing the uid. I didn't even have to change posts or change threads over. Just change uid and rebuild. Then I registered a new user after that, changed the uid to the account I created to replace the one that was deleted and now I have all of my members back with auto_increment working exactly the same as it would had the account not been deleted.
@Audentio: Full credit to bubulang for the solution Smile I was so happy when it worked for me!

p/s: Does this mean that your user managed to get the original UID back et. al? If so, that's really good!
Yes it is! I tried some logic and it actually worked. Why not just create a new user then edit his userid to the old one. It worked like a charm.

I was skeptical because I coulda sworn I tried this once on a less serious matter in the past and I thought I remember it not working. But it did. So, I didnt even have to change the posts or the threads over to the new username!
Thanks, Audentio. Next time I accidentally someone's account, I will be sure to try editing the user id. Smile

This is a really silly question, but was it simply just a matter of editing the userid in one table to the old one with phpMyAdmin?
That simple. Yup! To keep the auto_increment going, you need to create ANOTHER account then reset that userid to the one that you exchanged. But thats only if you are picky like me. I dont like user accounts to be deleted.