MySQL Forums
Forum List  »  Newbie

Re: Accidentally deleted root account - backup available, how to restore?
Posted by: valoonux
Date: March 27, 2006 12:43PM

Ok Sander I see the BIG problem but there's always a solution ;-)

Would you want to do this procedure before another one :
1/ Shutdown the mysqld (mysql server) using init script (something like /etc/init.d/mysqld stop) or if you cannot using the command "killall mysqld" (or "kill -9 yourprocesses") so you do not need to be root.
2/ go to your MYSQLINSTALLPATH/bin
and start mysqld directly with this command :
./mysqld_safe --skip-grant-tables --skip-networking
(nota --skip-networking is just for security, not necessary)

3/ another shell console
start the mysql client going to your MYSQLINSTALPATH/bin
and type : mysql (without any options)

4/type the following statements
mysql> flush privileges;
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yournewpassword');

5/ try to connect with another client with your new password
mysql -u root -pyournewpassword

If you cannot do this procedure (but i would be very surprised)
The only solution i see (may be someone else could help you more) is to shutdown your actual mysql server, install another mysql binary in another directory and :
- start this new mysql server.
- stop it
(the first time root has no password)
- do a binary copy of your actualserverdatadir/mysql (or tar)
- then copy the newserverdatadir/mysql directory to your actualserverdatadir/mysql

- finally restart your actual mysql server and client (root has no password)

Hope this helps

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.