Written by:David Aldridge
8/25/2010 1:20 PM 

Every now and then even the best of us will forget an important password - like our mysql server root password.  Or perhaps we inherit a running mysql system with no documentation from a previous administrator.  Either way, there comes a time when we simply have to reset the root password.  With mysql, as long as you have root access to the OS, it is not a difficult task.

First, login and stop the mysql process. How you do this will vary from linux to linux, but will either be:

/etc/init.d/mysql stop or service mysql stop

Next thing we need to do is to restart the mysql process, telling it to skip using the password table:

mysqld_safe --skip-grant-tables

Finally connect with the client:

mysql -u root

And then change the password for root:

use mysql;
update user set Password=PASSWORD('new-password-here') where user='root';
flush privileges;

Then exit the client, stop the running mysqld process and restart as normal.


Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Security Code
Enter the code shown above in the box below
Add Comment  Cancel 
You must be logged in and have permission to create or edit a blog.