Last active
March 7, 2018 07:42
-
-
Save dieunb/6c6d58214ec9cc8fbfde6e94e8489027 to your computer and use it in GitHub Desktop.
Reset MySQL root password on Macos
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
| If you don't remember the password you set for root and need to reset it, follow these steps: | |
| Stop the mysqld server, this varies per install | |
| Run the server in safe mode with privilege bypass | |
| sudo mysqld_safe --skip-grant-tables; | |
| In a new window connect to the database, set a new password and flush the permissions & quit: | |
| mysql -u root | |
| For MySQL older than MySQL 5.7 use: | |
| UPDATE mysql.user SET Password=PASSWORD('your-password') WHERE User='root'; | |
| For MySQL 5.7+ use: | |
| USE mysql; | |
| UPDATE mysql.user SET authentication_string=PASSWORD("your-password") WHERE User='root'; | |
| Refresh and quit: | |
| FLUSH PRIVILEGES; | |
| \q | |
| mysql> UPDATE mysql.user SET Password=PASSWORD('your_new_password') | |
| WHERE User='root'; | |
| ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. | |
| mysql> SET PASSWORD = PASSWORD('your_new_password'); | |
| Query OK, 0 rows affected, 1 warning (0.01 sec) | |
| Stop the safe mode server and start your regular server back. The new password should work now. Worked like a charm for me :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment