Reset Forgotten MySQL Root Password

Posted By Weston Ganger

I have forgotten my root password to MySQL before. This was a life saver.

It requires root access to the system obviously though.

# Start MySQL and skip the grant tables that store passwords
mysqld_safe --skip-grant-tables

# Connect to MySQL without a password
mysql --user=root mysql

# In the mysql prompt run the following commands:
UPDATE USER SET Password=PASSWORD('new_password') WHERE user='root';
flush privileges;

Then just kill your running mysqld and restart it normally.

Related External Links:

Article Topic:Software Development - Linux

Date:October 27, 2015