客户端连接报错
这个问题是因为用户在数据库服务器中的mysql数据库中的user的表中没有权限。
解决步骤
1、连接服务器: mysql -u root -p
2、看当前所有数据库:show databases;
3、进入mysql数据库:use mysql;
4、查看mysql数据库中所有的表:show tables;
5、查看user表中的数据:select Host, User,Password from user;
上面localhost表示只允许本地连接,不能远程连接
6、修改user表中的Host
%表示开启远程连接,且没有限制,在任何主机都可以登录;(%不包含localhost)
update user set Host='%' where User='root' and Host="localhost";,但是会出现下面的问题,最好是新增一行Host为%的数据
上面这样改了后,会导致xshell连接看不到所有的数据库(xshell表示本地连接,因为xshell先连接到服务器,然后在服务器登录数据库),localhost才表示本地连接(注意:上面localhost没有设置密码,所以本地连接,就不用密码;navicat表示远程连接,需要密码)
7、最后刷新一下:flush privileges;
8、重新在Navicate中测试一下:
声明:如有侵权,请联系删除。
============================= 升职加薪 ==========================