CentOS6开启MySQL远程访问

1.开放MySQL访问端口3306

 
修改防火墙配置文件
 
vi /etc/sysconfig/iptables 
 
加入端口配置     
 
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
 
重新加载规则
 
service iptables restart  
 
 
 
2.修改mysql库里的host
 
登录mysql;
 
use mysql
 
update user set host='%' where user='root' and host='localhost';
 
记得一定还得修改密码,因为这时密码已失效,虽然本地还可以原密码登录,可远程改了host后还是没法访问
 
Update user SET password=password("root") Where user='root'; 
 
flush privileges;
 
3.重启mysql,远程就可以访问了
 
service mysqld restart;
 
 
 
 CentOS7开启MySQL远程访问
CentOS7这个版本的防火墙默认使用的是firewall,与之前的版本使用iptables不一样。按如下方便配置防火墙:
 
1、关闭防火墙:sudo systemctl stop firewalld.service
 
 
2、关闭开机启动:sudo systemctl disable firewalld.service
 
 
 
3、安装iptables防火墙
 
执行以下命令安装iptables防火墙:sudo yum install iptables-services
 
4、配置iptables防火墙,打开指定端口(CentOS6一样)
 
5、设置iptables防火墙开机启动:sudo systemctl enable iptables
 
6、之后的和CentOS6一样


上一篇: PHP判断变量内容是什么编码(gbk?utf-8) mb_detect_encoding
下一篇: CentOS查看文件夹大小
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: centos
相关日志:
评论: 0 | 引用: 0 | 查看次数: 107
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭

 广告位

↑返回顶部↑