Reset MySQL Root Password

Reset MySQL Root Password

(Debian based example).

First, stop the daemon:

#/etc/init.d/mysqld stop

Second, start mysql without privileges:

#mysqld --skip-grant-tables &

Third, connect to the daemon and make changes:

#mysql
#UPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root';
#FLUSH PRIVILEGES;
#quit

Now stop the daemon and start it normally:

#/etc/init.d/mysql stop
#/etc/init.d/mysql start

It might be sufficient with a simple restart, but I like it the explicit way to be sure.

For more information on this subject, visit the official MySQL reference:
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html#resetting-permissions-unix

Leave a Reply