ERROR 1698 (28000): Access denied for user 'root'@'localhost' MySQL 链接错误问题解决
问题
无法链接至MySQL,1698报错.
场景
Ubuntu 18.04 Lts + Apache2 +MySQL +PHP
定位
出现在刚刚安装完MySQL的时候.
问题回溯
[email protected]:~$ mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
解决办法
1. root用户输入 mysql -u root -p
能否进入.
2. 能够进入
2.1 输入指令 :UPDATE mysql.user SET authentication_string=PASSWORD('你的密码'), PLUGIN='mysql_native_password' WHERE USER='root';
2.2 quit
退出
3.不能进入
3.1 使用cat命令查看默认用户名密码 sudo cat /etc/mysql/debian.cnf
3.2 使用查询出来的用户名和密码进入
3.3 输入指令: UPDATE mysql.user SET authentication_string=PASSWORD('你的密码'), PLUGIN='mysql_native_password' WHERE USER='root';
3.4 quit
退出
4.关闭并重新开启服务 /etc/init.d/mysql stop
/etc/init.d/mysql start
至此,问题解决.