简体   繁体   English

使用IP地址连接到mysql

[英]using IP address connect to mysql

I am using following code to connect to remote mysql from php application I am using WAMP server where i installed my php application and on remote side also wamp server is there. 我正在使用以下代码从php应用程序连接到远程mysql,我正在使用WAMP服务器,我在其中安装了我的php应用程序,并且在远程方面,wamp服务器也在那里。

$con=mysql_connect('xxxx:xxxx:xxxx:xxxx','root','');

But connection is not being established. 但是没有建立连接。 Following warning is coming... 以下警告即将来临...

Warning: mysql_connect() [function.mysql-connect]: [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. 警告:mysql_connect()[function.mysql-connect]:[2002] php_network_getaddresses:getaddrinfo失败:此类主机未知。 (trying to connect via tcp://10:133) (尝试通过tcp:// 10:133连接)

Please any body give me some idea ! 请任何人给我一些想法! thanks ! 谢谢 !

Should be dots not colons, like 应该是点而不是冒号,例如


$con=mysql_connect('xxxx.xxxx.xxxx.xxxx','root','');
//like
$con=mysql_connect('127.0.0.1','root','');

在您的IP地址中使用点而不是冒号。

try this: 尝试这个:

$con=mysql_connect('192.168.0.1','root','');

or if you want to specify the port: 或者如果您想指定端口:

$con=mysql_connect('192.168.0.1:3306','root','');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM