mysql远程连接 Host * is not allowed to connect to this MySQL server(第一次配置好lnmp环境)

时间:2022-08-20 19:45:15

1.第一次在linux上搭建好mysql,本机windows远程链接报错Host * is not allowed to connect to this MySQL server

mysql远程连接 Host * is not allowed to connect to this MySQL server(第一次配置好lnmp环境)

2.原因:mysql服务器出于安全考虑,默认只允许本地登录数据库服务器。

问题解决:登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%",然后重启mysql这样就允许所有的远程机器进行访问了。

步骤1:修改mysql表

mysql -u root -pvmware
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>flush privileges;
mysql>select host, user from user;

mysql>quit

mysql远程连接 Host * is not allowed to connect to this MySQL server(第一次配置好lnmp环境)

成功!!!!