Created
July 29, 2019 17:24
-
-
Save 777777miSSU7777777/b72bf69906420bc3ea7bdf367a57001d to your computer and use it in GitHub Desktop.
Reset root pass on MySQL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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