1、登陆mysql
mysql -u root -p
2、设置访问地址
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;
如果你想允许用户root从ip为192.168.1.123的主机连接到mysql服务器,并使用root作为密码
使用mysql库:use mysql
查询信息:select user,host from userupdate user set host="%" where user="root"
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.1.123‘IDENTIFIED BY ‘password‘ WITH GRANT OPTION;
3、刷新
flush privileges;
防火墙开启
1、开启端口3306
firewall-cmd --zone=public --add-port=3306/tcp --permanent
2、重启防火墙
firewall-cmd --reload
查看已经开放的端口:
firewall-cmd --list-ports