Last active
January 24, 2021 17:55
-
-
Save ValentinNikolaev/ffaf6d168dd936667ab04d85b6075fff to your computer and use it in GitHub Desktop.
Reset root mysql password Ubuntu
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
| sudo /etc/init.d/mysql stop | |
| sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking & | |
| Start the mysql client process using this command | |
| mysql -u root | |
| From the mysql prompt execute this command to be able to change any password | |
| FLUSH PRIVILEGES; | |
| Then reset/update your password | |
| SET PASSWORD FOR root@'localhost' = PASSWORD('password'); | |
| If you have a mysql root account that can connect from everywhere, you should also do: | |
| UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root'; | |
| Alternate Method: | |
| USE mysql | |
| UPDATE user SET Password = PASSWORD('newpwd') | |
| WHERE Host = 'localhost' AND User = 'root'; | |
| And if you have a root account that can access from everywhere: | |
| USE mysql | |
| UPDATE user SET Password = PASSWORD('newpwd') | |
| WHERE Host = '%' AND User = 'root'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment