/usr/local/mysql/bin/mysql -uroot -p
解決辦法:mysql
1.先中止mysql 服務linux
service mysqld stop
2.進入mysql安裝目錄bin/ 使用safe模式,進行重啓:sql
./mysqld_safe --skip-grant-tables
3.新開一個終端,使用root帳戶,無密碼登陸,修改root用戶密碼數據庫
/usr/local/mysql/bin/mysql -uroot
spa
use mysql update user set password=PASSWORD("你的密碼") where User = 'root';
5.7版本下的mysql數據庫下已經沒有password這個字段了,password字段改爲了authentication_string
update user set authentication_string=PASSWORD("你的密碼") where User = 'root';
4.重啓mysql,正常登陸3d
service mysqld restart 重啓
/usr/local/mysql/bin/mysql -uroot -p 而後輸入剛纔重置的密碼
完成,鏈接成功!rest