Mac下mysql忘记密码
-
Stop mysql in system reference.
-
sudo ./usr/local/mysql-5.7.13-osx10.11-x86_64/bin/mysqld_safe --skip-grant-tables
-
Use command
mysql
login in. -
Update password of root to null.
update mysql.user set authentication_string="" where user="root"; exit;
-
Set new password.
/usr/local/mysql-5.7.13-osx10.11-x86_64/bin/mysqladmin -u root -p password wanggang
mysql> update mysql.user set authentication_string=PASSWORD('gangwang') where user='root' and host='localhost';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
ysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'gangwang' ;
Query OK, 0 rows affected (0.10 sec)
mysql> update mysql.user set authentication_string=PASSWORD('gangwang') where user='root' and host='localhost';
Query OK, 0 rows affected, 1 warning (0.01 sec)
Rows matched: 1 Changed: 0 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit;
This work is licensed under a CC A-S 4.0 International License.