Reset MySQL Root Password

If you have mysql- or root user shell access to the linux host where your mysql is running, you can reset the password like this:

(Debian based example).

First, stop the daemon.
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 too, but I like it the explicit way just 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



Written by: Dag Jonny Nedrelid
©2007-2012 http://thronic.com


Feel free to leave a comment.
Name:
URL:
0