mysql版本 5.7.22
安裝完成后出現問題
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
可能是因為初始密碼為空;按空格回車后還是報一樣的錯
那只能使用mysql -udebian-sys-maint -p進入MySQL,這時你需要mysql提供給你的密碼
輸入 sudo vim /etc/mysql/debian.cnf
password就是密碼
進入后重新設置root賬號密碼UPDATE user SET authentication_string=PASSWORD('你的密碼') where USER='root';
退出重啟服務后還是報錯!但是密碼還是改成功了,查看select user,plugin from user
錯誤原因是因為 plugin root 的字段是auth_socket 改掉就行
update user set authentication_string =password('你的密碼'),plugin='msyql_native_password' where user='root'
niec 現在exit 退出
可以了
參考文章:https://www.cnblogs.com/leolztang/p/5094930.html