MAC 環境下初始化mysql root 密碼


 

1. 關掉mysql服務,打開系統設置最后的mysql,然后將mysql先關掉

 

2. 生成一個文件命名mysql-init,文件中放入:一句話,這句話不同版本不一樣,如下:(括號里面不包含)

alter user ‘root’@‘localhost’ identified by ‘新密碼’;(MySQL 5.7.6 and later)

set password for ‘root’@‘localhost’=password(‘新密碼’);(MySQL 5.7.5 and earlier)

 

3. cd /usr/local/mysql/bin/

sudo su

mysqld_safe —init-file=/home/me/mysql-init &

mysqld_safe —skip-grant-tables &

./mysql

flush privileges;

update mysql.user  set authentication_string = password(‘你在文件中定義的新密碼’),password_expired = ’N’ where user = ‘root’ and host = ‘localhost’;

flush privileges;

quit;

./mysql -u root -p

輸入你的新密碼就好了

參考:B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems小節(http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM