Posts Tagged “mysql”

Sometimes you need a quick and dirty way of resetting a MySQL root password. Typical scenario is when taking over Administrative duties on a server which has no documentation.

First we need stop MySQL and start it with the –skip-grant-tables option set:

sudo /etc/init.d/mysql stop
sudo mysqld --skip-grant-tables

Then we login to mysql as root:

mysql -u root mysql

Once logged in we can set the new password:

UPDATE user SET Password=PASSWORD('NewPassword') WHERE User='root';
FLUSH PRIVILEGES;
exit;

Warning: This is not the most secure way of doing this. I disconnect the server from the network before doing this, and reconnect after.

Tags: , ,

Comments No Comments »