mysql安装后默认是localhost访问,若是须要外部访问能够设置一个新的帐号把host改成%,意味着全部ip都可以访问mysql
grant all privileges on *.* to 'outUser'@'%' identified by '12' with grant option
而后sql
flush privileges;
就能够使用outUser帐户密码12来外部访问,有的时候没法访问须要打开防火墙开放端口centos
centos 7 中使用的是firewall-cmd命令ssh
# firewall-cmd --list-all-zones #查看全部的zone信息 # firewall-cmd --get-default-zone #查看默认zone是哪个 # firewall-cmd --zone=internal --change-zone=p3p1 #临时修改接口p3p1所属的zone为internal # firewall-cmd --add-service=http #暂时开放http # firewall-cmd --permanent --add-service=http #永久开放http # firewall-cmd --zone=public --add-port=80/tcp --permanent #在public中永久开放80端口 # firewall-cmd --permanent --zone=public --remove-service=ssh #从public zone中移除服务 # firewall-cmd --reload #从新加载配置
打开3306端口tcp
firewall-cmd --add-port=3306/tcp --permanent
okide