Host 'DESKTOP-BNFMG64' is not allowed to connect to this MySQL server解决方案

使用Navicat连接MySQL数据库,如果在本机上通过ip地址输入localhost是可以连接上的。但是我们想要通过以太网IPv4地址远程连接的方式,就会提示Host 'DESKTOP-BNFMG64' is not allowed to connect to this MySQL server即MySQL不允许远程登录,所以远程登录失败了。

解决办法:

方案一,直接修改root权限:

1.通过cmd进入mysql,即输入命令mysql -u root -p 密码

2.使用mysql,即输入命令use mysql;

3.修改字段user为root一列的的host字段为%,update user set host = '%' where user = 'root';

4.刷新MySQL的系统权限相关表,即输入命令flush privileges; 

方案二,创建一个新的用户user1,密码为123456:

1.输入命令create user user1 identified with mysql_native_password by '123456';
2.输入命令grant all on *.* to 'user1'@'%';
3.输入命令FLUSH PRIVILEGES;

发布了59 篇原创文章 · 获赞 13 · 访问量 2540

猜你喜欢

转载自blog.csdn.net/qq_40885085/article/details/102654872
今日推荐