Skip to main content

If you administer a server and have forgotten your MySQL password, do this...

# Reset 'root' password
# -----------------------------------------------------
# http://www.artfulsoftware.com/infotree/tip.php?id=784

# If you administer a server and have forgotten your MySQL password, do this:

# 1. Stop MySQL:

  /etc/init.d/mysql stop

# 2. Start the MySQL server without privilege tables:

  mysqld --skip-grant-tables

# 3. Start the mysql client:

  mysql

# 4. Find name of admin user (probably 'root'), update password:

  select user,host,password from mysql.user;

  reset password for admin user 'root' # -- (or whatever the name is)

  update mysql.user set password=PASSWORD('new_pass') where user='root';
  flush privileges;
  exit;

# 5. Stop mysqld, eg in another command window...

  mysqladmin shutdown

# 4. Restart MySQL:

  /etc/init.d/mysql start

# (In Windows, if you've not added the MySQL's bin folder to the system path,
#   you will have to navigate in the DOS window to that folder.)

# For more detail see:
# http://dev.mysql.com/doc/refman/5.5/en/resetting-permissions.html