boakes.org

Reset MySQL

Sometimes you forget the root password for your MySQL instance (because you don’t write it down, that would be silly). When this happens it’s useful to be able to disable the authentication and authorization engine. On Debian Linux I recommend a small script.


/etc/init.d/mysql stop
/etc/init.d/mysql start --skip-grant-tables

It can also be useful to have a second script prepared to reset the password, thus:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'YOUR_NEW_PASSWORD';
FLUSH PRIVILEGES;

then just run

/etc/init.d/mysql restart