Created
January 10, 2015 09:06
-
-
Save freretuc/a48761a5d387b023d2ee to your computer and use it in GitHub Desktop.
Unix : lost mysql root password
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
| /etc/init.d/mysql stop | |
| echo "UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES;" >> /home/mysql-init | |
| mysqld_safe --init-file=/home/mysql-init & | |
| rm /home/mysql-init | |
| /etc/init.d/mysql stop | |
| /etc/init.d/mysql start | |
| or | |
| /etc/init.d/mysql stop | |
| mysqld_safe --skip-grant-tables & | |
| mysql -u root | |
| (in mysql shell) | |
| mysql> use mysql; | |
| mysql> update user set password=PASSWORD("MyNewPass") where User='root'; | |
| mysql> flush privileges; | |
| mysql> quit | |
| /etc/init.d/mysql stop | |
| /etc/init.d/mysql start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment