1、cd /usr/local/mysql/bin/
2、sudo su
輸入之后會要求輸入你的計算機密碼,輸入的時候是什么都不顯示的,輸完后回車
3、 ./mysqld_safe --skip-grant-tables &
這一步的作用是跨過權限驗證
4、./mysql -u root
用另一窗口以root身份登錄,因為第三步的原因不需要密碼了。
5、 update user set authentication_string=‘root123’ where User='root';
Navicat 連接錯誤:
上一步執行之后本來以為已經可以登錄了,可是navicat連接測試時出現了:
ERROR 1862 (HY000): Your password has expired. To log in you must
change it using a client that supports expired passwords.
所以還需要下面兩步(我不用下面的步驟也可以用客戶端登錄了)
打開新的終端:
1、cd /usr/local/mysql/bin/
2、sudo su
3、./mysql -uroot -proot123
4、SET PASSWORD = PASSWORD('root123');
參考 http://blog.csdn.net/jia611/article/details/51553067