Skip to content

Instantly share code, notes, and snippets.

@tranduydat
Created January 14, 2023 17:33
Show Gist options
  • Save tranduydat/da94ccd5a9e12564fd700557a31a1418 to your computer and use it in GitHub Desktop.
Save tranduydat/da94ccd5a9e12564fd700557a31a1418 to your computer and use it in GitHub Desktop.
Reset MySQL 8 password
sudo systemctl stop mysql
sudo mysqld_safe --skip-grant-tables &
mysql -u root
UPDATE mysql.user SET authentication_string=null WHERE User='root';
flush_privileges;
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
exit;
ps -fea | grep mysqld
sudo kill -9 [pid from previous command]
# Credit: https://stackoverflow.com/questions/50691977/how-to-reset-the-root-password-in-mysql-8-0-11 @Ulises Layera
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment