Created
October 24, 2014 08:54
-
-
Save octavian-nita/9dccf8cc192ab8a65780 to your computer and use it in GitHub Desktop.
Reset forgotten MySQL root password (http://www.itsprite.com/linuxreset-forgotten-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
| #!/bin/sh | |
| sudo /etc/init.d/mysql stop | |
| # OR | |
| sudo /etc/init.d/mysqld stop | |
| sudo mysqld_safe --skip-grant-tables | |
| sudo mysql -u root << EOF | |
| use mysql; | |
| update user set password = PASSWORD("new-pwd") where user = 'root'; | |
| flush privileges; | |
| quit; | |
| EOF | |
| sudo /etc/init.d/mysql restart | |
| # OR | |
| sudo /etc/init.d/mysqld restart | |
| # TEST | |
| sudo mysql -u -p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment