在Openshift上从Zend_Db连接到MySQL时出现PDO错误

时间:2014-01-25 19:30:06

标签: php mysql .htaccess pdo openshift

当我尝试在OpenShift上从Zend_Db连接到MySQL时,我遇到了这个问题:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' in /var/lib/openshift/52e2f054e0b8cd9dba000122/app-root/runtime/repo/library/Zend/Controller/Plugin/Broker.php on line 336 PDOException: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /var/lib/openshift/52e2f054e0b8cd9dba000122/app-root/runtime/repo/library/Zend/Db/Adapter/Pdo/Abstract.php on line 129

我试图输入相关环境中的值。 Openshift在application.ini中创建的变量:

resources.db.adapter = "PDO_MYSQL"
resources.db.isdefaulttableadapter = true
resources.db.params.dbname = "XXXX"
resources.db.params.username = "XXXX"
resources.db.params.password = "XXXX"
resources.db.params.hostname = "127.5.203.2"
resources.db.params.charset = "UTF8"

我也在.htaccess文件中试过这个:

php_value mysql.default_socket "${OPENSHIFT_MYSQL_DB_SOCKET}"
php_value mysqli.default_socket "${OPENSHIFT_MYSQL_DB_SOCKET}"

也在index.php文件中:

 $openshiftsocket = getenv('OPENSHIFT_MYSQL_DB_SOCKET');
    //echo "OpenShift socket is [$openshiftsocket]";

    if (isset($openshiftsocket)) {
       echo 'foo';
       ini_set('mysql.default_socket', $openshiftsocket);
       ini_set('mysqli.default_socket', $openshiftsocket);
    }

但我一直收到错误。

0 个答案:

没有答案