在centos6.8上源碼安裝了MySQL5.7.20,進入mysql的時候報錯如下:
解決辦法如下:
在mysql的配置文件內加入:
vim /etc/my.cnf
skip-grant-tables
保存並重啟mysql服務
進入mysql,修改密碼:
mysql> use mysql;
mysql> update user set password=password("你的新密碼") where user="root";
mysql> flush privileges;
mysql> quit
到此root賬戶就重置了密碼,刪除etc/my.cnf中,剛添加的那行內容,重啟mysql就好了
如果在進行到
mysql> update user set password=password("你的新密碼") where user="root";
報錯:ERROR 1054 (42S22): Unknown column 'password' in 'field list'
解決措施如下:
mysql>desc user;
發現在Field列中沒有password,此時我們需要這樣重置密碼:
mysql>update user set authentication_string=password('你的新密碼') where user='root';
之后的步驟如上所示,就解決了這個問題