踩坑录-mysql不允许远程连接(错误码:1130) Host'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server“

每次搭建mysql环境都会遇见同样的问题,在此分享一下踩坑笔录。

一、问题描述

安装成功后,本地直接链接远程mysql,默认为不允许远程访问,则客户端提示1130 - Host'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server“。

二、解决办法简单粗暴

1、 进入mysql 安装目录bin 下,打开cmd,输入mysql -u root -p,然后回车,输入密码后回车,进入mysql命令行;
2、输入 user mysql;
3、输入 update user set host = '%' where user = 'root';
执行时会报如下错误,不用紧张;继续下一步
(You are using safe update mode and you tried to update a table without a WHERE clause that uses a KEY column.” )
4、输入 flush privileges;
5、输入 exit;
即可,再尝试连接,恭喜成功!

猜你喜欢

转载自www.cnblogs.com/xuyao100/p/10247790.html