摘要:本文主要向大家介绍了MySQL数据库之centos7 打开mysql 3306端口并 设置外部访问 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。
本文主要向大家介绍了MySQL数据库之centos7 打开mysql 3306端口并 设置外部访问 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。
mysql安装后默认是localhost访问,如果需要外部访问可以设置一个新的账号把host改为%,意味着所有ip均可以访问
grant all privileges on *.* to ‘outUser‘@‘%‘ identified by ‘12‘ with grant option
然后
flush privileges;
就可以使用outUser账户密码12来外部访问,有的时候无法访问需要打开防火墙开放端口
centos 7 中使用的是firewall-cmd命令
# 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端口
firewall-cmd --add-port=3306/tcp --permanent
ok
本文由职坐标整理并发布,希望对同学们学习MySQL有所帮助,更多内容请关注职坐标数据库MySQL数据库频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号