Professional Webmasters Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Recovering the MySQL root password

Go down

Recovering the MySQL root password Empty Recovering the MySQL root password

Post  andry Wed Aug 04, 2010 4:25 am


If you are unable to recall the password for MySQL root account you will need to reset it. Remember that by default MySQL root account has an empty password so try that first.



Login as root to the machine with the MySQL server (not to MySQL).
Stop the MySQL server by using either of the following command:

Code:
$ /etc/init.d/mysql stop

Now the MySQL server must be started so that it does not take user credentials into account:

Code:
$ <code>mysqld_safe --skip-grant-tables &</code>

Once MySQL has been started in this manner you (and anyone else who has access to this machine so be aware of inherent danger here!) can simply connect as root user without

password:

Code:
$ mysql -u root

Now simply change the root password and force MySQL server to take it into account:

Code:
mysql> use mysql;
mysql> update user set password=PASSWORD(“rootPassOfYoutChoice”) where user=’root’;
mysql> flush privileges;
mysql> quit

Once root password is changed we need to restart MySQL server because right now it is not taking user credentials into account:

Code:
$ /etc/init.d/mysql restart

After this point MySQL server will operate just as before with the root account having the new password.
andry
andry
Moderator
Moderator

Posts : 467
Join date : 2010-05-07

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum