is not allowed to connect to this mysql server

今天写了一个局域网连接连接mysql,提示:is not allowed to connect tothis mmysql server。

解决方案如下:

命令行下输入:

mysql -u root -p

登录到mysql中,提示:Enter password:时输入密码。

输入命令:

use mysql;
select host from user where user='root';

修改帐号不允许从远程登陆,只能在localhost的帐号。这个时候只要在localhost的那台电脑,登入MySQL后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"

update user set host = '%' where user ='root';

刷新配置。

flush privileges;

最后链接成功。

QQ截图20220722221333.png

打赏

0 评论

发表评论