Home  >  Article  >  Database  >  centos6.5下安装mysql,远程访问_MySQL

centos6.5下安装mysql,远程访问_MySQL

WBOY
WBOYOriginal
2016-06-01 12:58:381450browse

 

安装成功后,得做相应配置才能从别的机器访问mysql:

1.开放mysql访问端口3306

修改防火墙配置文件
vi /etc/sysconfig/iptables

加入端口配置
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -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,远程就可以访问了

ps:如果由于操作错误,本地得登录不了,可以通过

mysqld_safe --skip-grant-tables &

方式启动mysql,这里不用密码就可以登录mysql,改完后再通过正常方式启动

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn