远程连接mysql数据库 出现 is not allowed to connect to this MySQL server

远程连接 虚拟机或者服务器的mysql数据库

ps:这里是 windows系统下的mysql数据库

如果用Navicat Premium远程访问出现is not allowed to connect to this MySQL server
1.登录服务器,进入数据库
mysql -uroot -p密码
2.查看数据库用户
show databases;

3.切换用户,查看配置
use mysql;

select host from user where user='root';
如果出现的是
host
localhost

4.修改配置
update user set host = '%' where user ='root';
解释:将localhost设置为通配符%。
localhost设置了“%”后便可以允许远程访问。

5.使配置生效
localhost修改完成后执行以下命令使配置立即生效。
flush privileges;
然后在查看配置
select host from user where user='root';
这时候就是
host
%

这时候就可以了

posted @ 2021-08-03 15:16  小鲤鱼丿[小白]  阅读(569)  评论(0)    收藏  举报