| Monday November 24th 2014


Subscribe by email:

We promise not to spam/sell you.

Search Amazon deals:

HOWTO: Reset a forgotten MySQL root password

Thankfully there is a simple solution to this problem, we just need to start MySQL with a flag to tell it to ignore any username/password restrictions which might be in place. Once that is done you can successfully update the stored details.

MySQLLogin or su as root to the machine with the MySQL server.

Stop the MySQL server by using the following command:

# /etc/init.d/mysql stop

Next, start the MySQL server without password:

# mysqld_safe --skip-grant-tables &

Connect to MySQL server using the following command:

# mysql --user=root mysql

Now you should have a MySQL prompt. Enter the following commands:
mysql> update user set Password=PASSWORD('type-new-password-here') WHERE User='root';
mysql> flush privileges;
mysql> quit

Note: Replace type-new-password-here 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 by typing fg and hitting Ctrl +C to kill the process or using the following command:

# /etc/init.d/mysql stop

Start mysql server using the following command

# /etc/init.d/mysql start

Related Posts: On this day...

Leave a Reply

You must be logged in to post a comment.