首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

PHP使用IP地址联接MySQL数据库

2013-10-12 
PHP使用IP地址连接MySQL数据库我们通常测试的时候都是用mysql_connect(localhost,usrname,password)

PHP使用IP地址连接MySQL数据库

我们通常测试的时候都是用mysql_connect("localhost","usrname","password");的方式来连接MySQL数据库的,

如果我们要通过其他主机使用IP地址来连接MySQL数据库的时候,就需要修改MySQL的配置文件/etc/mysql/my.cnf,否则会出现这样的错误提示:

can t connect to mysql server on 111 

skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address           = 127.0.0.1 //这一行是要注释掉的

只要注释掉这一行bind-address之后再重启mysql就可以通过其他机器使用IP地址来连接mysql了。

热点排行