Skip to content

Instantly share code, notes, and snippets.

@wamith
Last active April 18, 2019 05:29
Show Gist options
  • Save wamith/8ef76f5bec7ff0addef1a3d3b72ed2bf to your computer and use it in GitHub Desktop.
Save wamith/8ef76f5bec7ff0addef1a3d3b72ed2bf to your computer and use it in GitHub Desktop.
Fix MySQL expired password issue
# expired MySQL password
systemctl stop mysqld
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
systemctl start mysqld
# login to the console and change the password
mysql -u root
UPDATE mysql.user SET authentication_string = PASSWORD('password123') WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
-- set passwords to never expire (optional)
SET GLOBAL default_password_lifetime = 0;
exit
# restart MySQL
systemctl stop mysqld
systemctl unset-environment MYSQLD_OPTS
systemctl start mysqld
# try and login with the new password
mysql -u root -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment