Recover MySQL Database root password
Posted by Admin on April 7th, 2007
Login as root to the Unix-like (Unix, Linux or BSD) machine with the MySQL server.
Stop the MySQL server by using either of the following command
#/etc/init.d/mysql stop
Now you need to Start MySQL server without password
# mysqld_safe --skip-grant-tables &
Connect to mysql server using mysql client with the following command
# mysql -u root
Now you should be having mysql prompt
mysql>
Now you need to Setup new MySQL root user password
mysql> use mysql;
mysql> update user set password=PASSWORD(“newrootpassword”) where user=’root’;
mysql> flush privileges;
mysql> quit
Note: Replace newrootpassword with the new root password for MySQL server. Flush Privileges is needed to making the password change effect immediately.
Now you need to Stop MySQL Server using the following command
# /etc/init.d/mysql stop
Test Your New Mysql root password
First you need to start mysql server using the following command
# /etc/init.d/mysql start
# mysql -u root -p
Now it will prompt for root password and enter your new root password

May 21st, 2007 at 6:54 am
Thank you thank you thank you… major lack of help for Debian in this area.
October 14th, 2008 at 6:22 am
Sweeet, it works, been look all over the net for hours for this, this is awesome. thanks so much…
July 8th, 2009 at 1:58 am
hi, I need help.is there anyone can help me on ubuntu MYSQL issue?
August 18th, 2009 at 12:07 pm
What kind of help do you need with Ubuntu, maybe i can help
September 25th, 2009 at 2:35 pm
Thanks very much!!
March 20th, 2010 at 7:33 am
It works great!
thank u