我在一台WIN03的服务器上安装了mysql,新建了一个数据库,然后新建账户,开启远程连接,我可以通过第三方的软件navicat链接,能成功连接,并能操作,但我通过php写好的代码链接的时候就出错了
链接代码如下
<?php
$hostname="ip:1234";//端口我修改过了
$username="myloginusername";
$password="myloginpassword";
$dbname="thedatabase";
$conn=mysql_connect($hostname,$username, $password);
mysql_select_db($dbname,$conn);$info=$_POST['info'];
$exec="insert into thetable (info) values ('".$info."')";
$result=mysql_query($exec) or die(mysql_errno.'-'.mysql_error());
echo " <Script>location.replace('ok.php'); </Script> ";
exit();
?>
提示出错如下Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /home/content/17/5288617/html/
Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/17/5288617/html/
mysql_errno-Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)请问这个问题该如何解决呢?
链接代码如下
<?php
$hostname="ip:1234";//端口我修改过了
$username="myloginusername";
$password="myloginpassword";
$dbname="thedatabase";
$conn=mysql_connect($hostname,$username, $password);
mysql_select_db($dbname,$conn);$info=$_POST['info'];
$exec="insert into thetable (info) values ('".$info."')";
$result=mysql_query($exec) or die(mysql_errno.'-'.mysql_error());
echo " <Script>location.replace('ok.php'); </Script> ";
exit();
?>
提示出错如下Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /home/content/17/5288617/html/
Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/17/5288617/html/
mysql_errno-Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)请问这个问题该如何解决呢?
http://zhidao.baidu.com/question/44369444
http://forums.mysql.com/read.php?52,151255,156258
http://www.xishuiw.com/info/2009-3/2009-3-3-16440.htm
http://zhidao.baidu.com/question/87870784遇到问题多用搜索引擎
WINDOWS怎么会有这样的路径呢?'/var/lib/mysql/mysql.sock' 是不是PHP的配置有问题?有个指定mysql.sock的配置,是不是错了?