Linux(Ubuntu、CentOS)下开放 MySQL 服务远程访问

2014-8-24   /   字数:372   /   阅读数:7648   /   分类: Web     

CentOS 直接跳到第二步。

第一步,修改配置文件:

Ubuntu(CentOS 直接跳到第二步):

vim /etc/mysql/my.cnf

找到:

bind-address = 127.0.0.1

改为:

bind-address = 0.0.0.0
#允许任意ip地址访问

也可以指定IP地址。

然后重启MySQL:

sudo /etc/init.d/mysqld restart


第二步,修改数据库配置:

授权root用户进行远程连接,注意替换 “password” 为 root 用户真正的密码:

grant all privileges on *.* to root@"%" identified by "password" with grant option;
flush privileges;

第二行命令使设置生效,可以马上连接。


WRITTEN BY

avatar
标签: 远程 mysql

发表评论:

© 2011-2024 岁寒  |  Powered by Emlog