任何人都告诉我为什么我会收到此错误?首先我的互联网连接今天不错,所以我得到这个错误。我可以解决这个问题任何想法吗?
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] A
connection attempt failed because the connected party did not properly respond after a
period of time, or established connection failed because connected host has failed to
respond. ' in D:\SVN
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Pdo\Abstract.php:129
Stack trace: #0 D:\SVN
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Pdo\Abstract.php(129):
PDO->__construct('mysql:host=192....', 'root', 'root', Array) #1 D:\SVN
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Pdo\Mysql.php(109):
Zend_Db_Adapter_Pdo_Abstract->_connect() #2 D:\SVN
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Abstract.php(860):
Zend_Db_Adapter_Pdo_Mysql->_connect() #3 D:\SVN
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Abstract.php(930):
Zend_Db_Adapter_Abstract->quote('testing', NULL) #4 D:\SVN
data\WebClient_PHP\trunk\p\library\Zend\Auth\Adapter\DbTable.php(449): Zen
in D:\SVN
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Pdo\Abstract.php on line
144
这是我的config.ini
[general]
db.adapter = PDO_MYSQL
db.params.host = 192.168.0.233
db.params.username = root
db.params.password = my_password
db.params.dbname = "mydatabasename"
我的index.php中的一些代码
$config = new Zend_Config_Ini(ROOT_DIR.'/application/config.ini', 'general');
$DB = Zend_Db::factory($config->db);
Zend_Db_Table::setDefaultAdapter($DB);
答案 0 :(得分:8)
似乎你的代码这部分不起作用
[general]
db.adapter = PDO_MYSQL
db.params.host = 192.168.0.233
db.params.username = root
db.params.password = my_password
db.params.dbname = "mydatabasename"
要么IP不正确,如果是这样去windows中的cmd并输入ipconfig你将得到正确的ip粘贴它或者只是简单地写
db.params.host = localhost
当且仅当您在本地使用时可能有效。
答案 1 :(得分:3)
对于主机名/主机尝试使用Zend Server中的凭据 - > PHP Cloud选项卡 - >概述页面 - >用户参数选项卡...然后在凭据中创建“主机”部分,如下所示:
[general]
db.adapter = PDO_MYSQL
db.params.host = CONTAINERNAME-db.my.phpcloud.com
db.params.username = ZEND_DB_USERNAME
db.params.password = ZEND_DB_USERNAME
db.params.dbname = ZEND_DB_DBNAME
答案 2 :(得分:0)
你检查过mysql数据库了吗?
如果您确定,请检查您的适配器配置是否正常,可能是主机参数配置不正确。