mysql 开放远程连接 & 开放防火墙端口

感谢:

  https://www.cnblogs.com/feigao/p/10715547.html

  

 

Mysql默认不允许远程登录,所以需要开启远程访问权限

     可以先查看user表

     select user,authentication_string,host from user;

     

     默认都是localhost

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

      

      此时root的host是所有都可以了

      然后刷新修改,FLUSH PRIVILEGES;

      这步一定要做,否则无法生效。

 

防火墙开启

1、开启端口3306

firewall-cmd --zone=public --add-port=3306/tcp --permanent

2、重启防火墙

firewall-cmd --reload

查看已经开放的端口:

firewall-cmd --list-ports

  

posted @ 2021-03-09 14:18  我会一直笑  阅读(590)  评论(0编辑  收藏  举报