Back to How-to

Reset MySQL root password

This is taken from various places, in particular here. This approach worked for me under Windows XP, using MySQL 5.1. I had already added the exectuables path to the DOS path using
path=%path%;"C:\Program Files\MySQL\MySQL Server 5.1\bin".
  1. Turn off the MySQL service, if it's already running, using the Control Panel -> Administrative Tools (Systeembeheer) -> Services.
  2. In a command line window, type mysqld --skip-grant-tables. Leave it hanging. I take it this opens a MySQL daemon that lets you enter as root without a password.
  3. In a second command line window enter mysql -u root mysql. Now it lets you in.
  4. In the MySQL prompt, run these following two commands:
    UPDATE user SET password=PASSWORD("topsecret") WHERE user="root";
  5. Quit MySQL and close the first command line window. Now you should be able to access MySQL as root using topsecret as the password after mysql -u root -p.