1.开启端口3306
输入firewall-cmd --zone=public --add=3306/tcp --permanent
本电脑已经开通了3306端口,因此提示已经开通,如果第一次开庭,只显示success
2.重启防火墙
firewall-cmd --reload
3.查看已开放的端口
firewall-cmd --list-ports
至此已经开通3306端口
拓展:
默认的root用户只能当前节点localhost访问,是无法远程访问的,我们还需要创建一个root账户,用户远程访问
先登录数据库
创建用户
create user 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1234';
create user 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1234';
并给root用户分配权限
grant all on *.* to 'root'@'%';
grant all on *.* to 'root'@'%';