- 在安装Mysql数据库的服务器上登陆root用户:
mysql -u root -p
image.png
- 切换数据库,查看user表中host信息
use mysql;
select host from user where user = 'root';
image.png
- 将localhost修改为通配符%
host列制定了允许用户远程登录的IP,指定为通配符%,表示不限制远程访问。
注意:在生产环境下不能为了省事将host设置为%,这样做会存在安全问题,具体的设置可以根据生产环境的IP进行设置;
update user set host = '%' where user = 'root';
- 执行flush privileges使配置生效
flush privileges;
网友评论