Resetting the MySQL root password

If you have forgotten your MySQL root password, you can reset it if you have physical access to the machine mysql is running on:

  1. Find the .pid file of the mysql process. It is either called mysql.pid or machinename.pid. Kill the mysql process. On my MacOS X server e.g. kill `cat /usr/local/mysql-standard-4.0.16-apple-darwin6.6-powerpc/data/localhost.pid`
  2. Restart the mysql server /usr/local/mysql-standard-4.0.16-apple-darwin6.6-powerpc/bin/mysqld_safe --skip-grant-tables &
  3. Set the new root password (replace newpassword with the new password!) /usr/local/mysql-standard-4.0.16-apple-darwin6.6-powerpc/bin/mysqladmin -u root flush-privileges password "newpassword"
    1. Done!