现在的位置: 首页 > 综合 > 正文

ubuntu12.04 配置mysql允许远程访问

2012年12月12日 ⁄ 综合 ⁄ 共 700字 ⁄ 字号 评论关闭

首先,修改/etc/mysql目录下面的my.cnf文件,把其中的bind-address设置为你的ip,假设为192.168.0.240

[bash]

bind-address =  192.168.0.240

[/bash]

我的mysql 版本如下:

[bash]

mysql  Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (x86_64) using readline 6.2

[/bash]

没有skip-network,所以只需要修改bind-address就可以了,保存

然后,重启mysql

[bash]

sudo service mysql restart

[/bash]

或者

[bash]

sudo /etc/init.d/mysql restart

[/bash]

最后,登陆mysql,执行如下命令:

[bash]

grant all privileges on *.* to 'root'@'%' identified by 'yourpassword'  with grant option;

flush privileges;

[/bash]

把yourpassword替换为你的数据库密码,'%'表示任何ip地址都可以访问数据库,你也可以替换为特定的ip

再次远程访问,就可以了。

参考:

1. http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

2. http://stackoverflow.com/questions/8380797/enable-remote-mysql-connection

抱歉!评论已关闭.