1. 下載mysql for mac: https://dev.mysql.com/downloads/mysql/
2. 雙擊mysql-5.7.17-macos10.12-x86_64.dmg進(jìn)行解壓, 雙擊mysql-5.7.17-macos10.12-x86_64.pkg進(jìn)行安裝
- Continue -> Continue, Agree -> Install -> 輸入管理員密碼
4. 記錄下來彈窗中的密碼
5. 進(jìn)入系統(tǒng)偏好設(shè)置, 找到mysql, 啟動服務(wù)
6. 將mysql的命令添加到系統(tǒng)中
(1).進(jìn)入/usr/local/mysql/bin,查看此目錄下是否有mysql
(2).執(zhí)行vim ~/.bash_profile
在該文件中添加mysql/bin的目錄
PATH=$PATH:/usr/local/mysql/bin
添加完成后,按esc笋鄙,然后輸入wq保存近顷。
(3).最后在命令行輸入source ~/.bash_profile
7. 通過mysql -uroot -p登錄mysql, 輸入之前保存的密碼
8. 重置mysql初始密碼
[sql] view plaincopy
<embed id="ZeroClipboardMovie_1" src="https://csdnimg.cn/public/highlighter/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="16" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&width=16&height=16" wmode="transparent" style="box-sizing: border-box;">
- SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');