HHVM连接mariadb失败

时间:2014-08-11 07:25:44

标签: php mysql hhvm

HHVM无法连接到 mariadb mysqldb ,但是php可以,我不知道为什么,有人请帮帮我。

[root@localhost /]#hhvm --version

HipHop VM 3.2.0 (rel)
Compiler: 1407404220_188959187
Repo schema: 190259736_1407404220

[root@localhost /]#php /var/www/html/test.php

Tom
Jack

[root@localhost /]#hhvm /var/www/html/test.php

Warning: mysql_connect(): Can't connect to MySQL server on '192.168.135.142' (4) in /var/www/html/test.php on line 2
Could not connect: Can't connect to MySQL server on '192.168.135.142' (4)

/var/www/html/test.php中的代码:

<?php
$con = mysql_connect("192.168.135.142","admin","123");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$result = mysql_query("SELECT * FROM mytest");
while($row = mysql_fetch_array($result))
{
    echo $row['name'];
    echo "<br />";
}
mysql_close($con);
?>

1 个答案:

答案 0 :(得分:1)

我已成功连接到mariadb。只需找到my.cnf,并添加:[mysqld]下面的skip-name-resolve,以及mysql_connect工作。