日期:2014-05-16  浏览次数:20826 次

mysql设置允许外部访问

配置外部访问帐号密码

本地登录mysql

mysql -uroot -p
?

执行

grant all on *.* to rails@'client_ip' identified by 'password' with grant option;
?

例子:所有局域网客户端都可访问

grant all on *.* to root@'192.168.0.%' identified by 'root' with grant option;
?

例子:为boyu数据库设置用户boyu

grant all on boyu.* to boyu@'192.168.0.%' identified by 'p4ssword';
?app_server_id为APP应用服务器的IP

?

设置mysql外部能访问

/etc/mysql/my.cnf

注释到下面这行

bind-address = 127.0.0.1
?

重启mysql-server

sudo service mysql restart
?