远程连接mysql报错【1130 -host 'localhost' is not allowed to connect to this mysql server】

时间:2023-03-09 03:42:46
远程连接mysql报错【1130 -host 'localhost' is not allowed to connect to this mysql server】

远程连接mysql时包如下错误:

1130 -host 'localhost' is not allowed to connect to this mysql server

解决办法

本地用root账号登陆mysql,修改mysql数据库的user表将host字段改为%。命令如下

mysql -uroot –p123
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';

OK搞定!