mysqli :: real_connect():( HY000 / 2005):未知的MySQL服务器主机

时间:2013-12-24 11:54:47

标签: php mysql codeigniter mysqli updates

我的SSH服务器上有一个MySQL隧道,指向另一个MySQL服务器。

我正在Codeigniter升级我的数据库驱动程序。这意味着使用PHP MySQL潜水员一切正常。更新我的文件并更改我的连接配置数组

来自:

        $config['hostname'] = "127.0.0.1:1111";
        $config['username'] = "user";
        $config['password'] = XXXX;
        $config['database'] = "Mydb";
        $config['dbdriver'] = "mysql";
        .
        .
        .
        .

要:

        $config['hostname'] = "127.0.0.1:1111";
        $config['username'] = "user";
        $config['password'] = XXXX;
        $config['database'] = "Mydb";
        $config['dbdriver'] = "mysqli";
        .
        .
        .
        .

我开始收到这些错误:

 ERROR - 2013-12-24 11:29:37 --> Severity: Warning  --> mysqli::real_connect(): (HY000/2005): Unknown MySQL server host '127.0.0.1:1111' (0) /var/www/app/system/database/drivers/mysqli/mysqli_driver.php 110
 ERROR - 2013-12-24 11:29:37 --> Unable to connect to the database

当我恢复到$config['dbdriver'] = "mysql";时,它再次起作用,因此文件很好。

MySQLi驱动程序无法通过本地隧道连接吗?

我该如何解决这个问题?如果MySQLi无法连接到隧道,那么我该如何更新我的系统?

注意:本地数据库(127.0.0.1)工作正常,它只是失败的隧道连接。

1 个答案:

答案 0 :(得分:1)

您可以指定或提供您的端口号,如下所示

mysqli mysqli_connect ([ string $host = ini_get("mysqli.default_host") [, string $username = ini_get("mysqli.default_user") [, string $passwd = ini_get("mysqli.default_pw") [, string $dbname = "" [, int $port = ini_get("mysqli.default_port") [, string $socket = ini_get("mysqli.default_socket") ]]]]]] )

语法:

$mysqli = new mysqli("localhost", "user","password","database", "3306"); //port is a string!