Skip to content

Instantly share code, notes, and snippets.

@atuanpham
Created June 8, 2016 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atuanpham/d06af37b96feec9d76000b351ee0a54e to your computer and use it in GitHub Desktop.
Save atuanpham/d06af37b96feec9d76000b351ee0a54e to your computer and use it in GitHub Desktop.
Reset root's password when the password is expired.
  • Stop mysqld service

  • Add to /etc/my.cnf with the following option:

skip-grant-tables
  • Start mysql

  • Connect to the mysql server using mysql client:

mysql
  • Reload grant tables
mysql> FLUSH PRIVILEGES
  • Change the root account password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
  • Remove skip-grant-tables from /etc/my.cnf file

  • Restart mysql server

and you should now be able to connect to mysql server as root using new password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment