Over a million developers have joined DZone.
Platinum Partner

Reset MySQL Root Password On Linux

· Java Zone

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

 

 Five easy steps to reset MySQL root password.

  1. Stop the MySQL server.
  2. Start the MySQL server with the --skip-grant-tables option. (it will not prompt for password)
  3. Connect to MySQL server as the root user. 
  4. Setup new MySQL root password.
  5. Exit and restart the MySQL server. 

    
### Shell Commands ###
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables & 
mysql -u root

### SQL Commands ###
use mysql;
UPDATE user SET password=PASSWORD("new-password") WHERE user='root';
flush privileges;
exit

### Shell Commands ###
/etc/init.d/mysql stop
/etc/init.d/mysql start
mysql -u root -pnew-password  

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}