Over a million developers have joined DZone.

Reset MySQL Root Password On Linux

· Java Zone

Easily build powerful user management, authentication, and authorization into your web and mobile applications. Download this Forrester report on the new landscape of Customer Identity and Access Management, brought to you in partnership with Stormpath.

 

 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 by Stormpath—a complete, pre-built User Management API. Want to learn how to use JWTs to protect microservices from CSRF and more? Check out this on-demand webinar with our Java Developer Evangelist, Micah Silverman.

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

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

{{ parent.tldr }}

{{ parent.urlSource.name }}