≡ Menu

Lost MySQL Admin Password

I lost mysql admin (root user) password. How do I reset a lost MySQL admin (root) password under UNIX or Linux or BSD operating systems?

Type the following commands. First, stop current MySQL database server:
/etc/init.d/mysql stop
/etc/init.d/mysqld stop
/usr/local/etc/rc.d/mysql-server stop

Now, start mysql server without password so that you can restart the password:
mysqld_safe --skip-grant-tables &
Login without a password, enter:
mysql -u root
Finally, setup a new MySQL root user password, enter::

USE mysql;
FLUSH privileges;

Replace NEW-ROOT-PASSWORD with actual password you want to use. Restart running mysql server:
/etc/init.d/mysql restart
Test it:
mysql -u root -p

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 2 comments… add one }
  • santosamaru April 13, 2010, 4:26 pm

    sir would you help me sir , i have problem with using ubuntu
    its my brother 6years old have changing my user privileges and set its none , i also cant goes as a root ,(crying)ehm i dont know how to set it back also i cant us my password in terminal to sudo su , its wont work did you know how i can get its back without reinstalling ?
    please help me sir

  • niro January 4, 2012, 10:53 am

    Thanks alot!

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , ,