Powered by a whole foods plant based diet, a well dressed penguin and an over-active imagination

Reset MySQL Password

I installed MediaWiki on a server at work yesterday. The web install is pretty straight forward, even I could get it right.

One thing I learnt was how to reset the root password on an MySQL database when it is not known-

1. stop MySQL (init.d/mysql stop)

2. Restart mysqld with the –skip-grant-tables option (I just added that argument to the init.d script and removed it after).

3. Connect to the mysqld server:
# mysql -u root mysql

4. At the mysql prompt:
mysql> UPDATE user SET Password=PASSWORD(‘newpasswd’)
WHERE User=‘root’;

5. Stop mysqld and restart it normally.

6. test!
# mysql -u root -p