Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save 777777miSSU7777777/b72bf69906420bc3ea7bdf367a57001d to your computer and use it in GitHub Desktop.

Select an option

Save 777777miSSU7777777/b72bf69906420bc3ea7bdf367a57001d to your computer and use it in GitHub Desktop.
Reset root pass on MySQL.
// Stop mysql server.
sudo systemctl stop mysql
// Run mysql server w/o privileges and networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
// If appears: "mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists", then run following commands:
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
// They try again to run.
sudo mysqld_safe --skip-grant-tables --skip-networking &
// Flush privileges.
FLUSH PRIVILEGES;
// Set new password.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_pass';
// If previous cmd doesnt work.
UPDATE mysql.user SET authentication_string = PASSWORD('new_pass') WHERE User = 'root' AND Host = 'localhost';
// Exit.
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment