Ubuntu16.04 ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决流程

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

 

posted @ 2018-07-18 02:52  DDDDyun  阅读(28475)  评论(2编辑  收藏  举报