CentOS系统Mysql 5.7 开启远程连接

发布时间:2020年10月28日 阅读:328 次

CentOS系统安装好MySQL后,默认情况下不支持用户通过非本机连接上数据库服务器,下面是解决方法:

1、在控制台执行

mysql -uroot -p

1.png

2、选择数据库

use mysql;

2.png

开启远程连接 root 用户名 % 所有人都可以访问 password 密码

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

刷新规则

FLUSH PRIVILEGES; 

3、重启mysql服务

service mysqld restart

3.png

如果执行完以上步骤,还是不能远程连接,那么我们需要查看服务器的防火墙是否开启

firewall-cmd --state

4.png

如果防火墙开启,请关闭

systemctl stop firewalld 临时关闭防火墙

5.png

systemctl disable firewalld 禁止防火墙开机启动

6.png

到此就可以远程连接了! 


Tag:
相关文章

发表评论: