MySQL 连接出现 is not allowed to connect to this MySQL Server错误提示
打开 MySQL8.0 Command Line Client
1. 打开远程连接
mysql> use mysql;
mysql> update user set user.Host=’%’ where user.User=‘root’;
mysql> flush privileges;
mysql> select host,user from user;
注:将Host设置为‘%’表示任意IP都能连接MySQL,也可以将‘%’改为指定ip

2. 关闭远程连接
如果有关闭远程连接的需求,其实我们只需要Host恢复成默认设置(只能本地连接)即可,如下:
mysql> use mysql;
mysql> update user set user.Host=‘localhost’ where user.User=‘root’;
mysql> flush privileges;
mysql> select host,user from user;

文章介绍了如何处理MySQL服务器不允许连接的问题。首先,通过更新users表,将root用户的Host设置为%以允许任何IP远程连接。然后,使用flushprivileges命令使更改生效。若需关闭远程连接,只需将Host改回localhost。
935

被折叠的 条评论
为什么被折叠?



