一:您是否忘記了Mac OS 的MySQL的root密碼? 通過以下4步就可重新設(shè)置新密碼:
1. ?停止 mysql server. ?通常是在 '系統(tǒng)偏好設(shè)置' > MySQL > 'Stop MySQL Server'
2. ?打開終端迎捺,輸入:
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
3. ?打開另一個(gè)新終端举畸,依次輸入:
1) sudo /usr/local/mysql/bin/mysql -u root
2)UPDATE mysql.user SET authentication_string=PASSWORD('新密碼') WHERE User='root';
3)FLUSH PRIVILEGES;
4)\q
4. ?重啟MySQL.
*以上方法針對 MySQL V5.7.9, 舊版的mysql請使用:UPDATE mysql.user SET Password=PASSWORD('新密碼') WHERE User='root';
二:安裝完mysql 之后,登陸以后凳枝,不管運(yùn)行任何命令抄沮,總是提示這個(gè):mac mysql error You must reset your password using ALTER USER statement before executing this statement.
step 1:?SET PASSWORD = PASSWORD('your new password');
step 2:?ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
step 3:?flush privileges;
完成以上三步退出再登跋核,使用新設(shè)置的密碼就行了,以上除了紅色的自己修改成新密碼外叛买,其他原樣輸入即可
參考1:?https://dev.mysql.com/doc/refman/5.6/en/alter-user.html
參考2:?http://dev.mysql.com/doc/refman/5.7/en/password-expiration-policy.html
參考3:?http://stackoverflow.com/questions/33467337/reset-mysql-root-password-using-alter-user-statement-after-install-on-mac
三:如何使用命令玩轉(zhuǎn)mysql