Home  >  Article  >  Database  >  ubuntu12.04 配置mysql允许远程访问

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

WBOY
WBOYOriginal
2016-06-07 15:52:341147browse

首先,修改/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 read

首先,修改/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

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