問題描述
我正在使用 Zend Framework 開發(fā)我的應(yīng)用程序,并嘗試連接到局域網(wǎng)中的遠(yuǎn)程 MySQL 數(shù)據(jù)庫.
Zend 中的數(shù)據(jù)庫連接設(shè)置如下:<前>[一般的]db.adapter = PDO_MYSQLdb.params.host = 192.168.1.2db.params.port = 3306
[現(xiàn)場直播:一般]db.params.username = rootdb.params.password = **db.params.dbname = djudd
[開發(fā):一般]db.params.username = rootdb.params.password = **db.params.dbname = 恒星引擎
我收到以下錯誤:
<塊引用><塊引用><塊引用>致命錯誤:未捕獲的異常 'PDOException' 帶有消息 'SQLSTATE[HY000] [2013] 在'讀取初始通信數(shù)據(jù)包'時失去與 MySQL 服務(wù)器的連接,系統(tǒng)錯誤:/usr/share/php/中的 111'Zend/Db/Adapter/Pdo/Abstract.php:129 堆棧跟蹤:#0/usr/share/php/Zend/Db/Adapter/Pdo/Abstract.php(129): PDO->__construct('mysql:host=192....', 'root', 'password', Array) #1/usr/share/php/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect() #2/usr/share/php/Zend/Db/Adapter/Abstract.php(448): Zend_Db_Adapter_Pdo_Mysql->_connect() #3/usr/share/php/Zend/Db/Adapter/Pdo/Abstract.php(238)): Zend_Db_Adapter_Abstract->query('DESCRIBE
bny_c...', Array) #4/usr/share/php/Zend/Db/Adapter/Pdo/Mysql.php(156): Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBE bny_c...') #5/usr/share/php/Zend/Db/Table/Abstract.php(823): Zend_Db_Adapter_Pdo_Mysql->describeTable('bny_core_module...', NULL) #6/usr/share/php/Zend/Db/Table/Abstract.php(866): Zend_Db_Table_Abstract->_setupMetadata() #7/usr/share/php/Zend/Db/Table/Abstract.在/usr/share/php/Zend/Db/Adapter/Pdo/Abstract.php 第 144 行
請幫我解決這個問題.
上次我遇到這種類型的錯誤時,我不得不將我的主機(jī)從:127.0.0.1 更改為 'localhost' 然后它工作正常.
I am using Zend Framework to develop my application and I try to connect to a remote MySQL database in my LAN.
The database connection settings in Zend is as follows:
[GENERAL] db.adapter = PDO_MYSQL db.params.host = 192.168.1.2 db.params.port = 3306[LIVE:GENERAL] db.params.username = root db.params.password = ** db.params.dbname = djudd
[DEVELOPMENT:GENERAL] db.params.username = root db.params.password = ** db.params.dbname = stellarengine
I got the following error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 111' in /usr/share/php/Zend/Db/Adapter/Pdo/Abstract.php:129 Stack trace: #0 /usr/share/php/Zend/Db/Adapter/Pdo/Abstract.php(129): PDO->__construct('mysql:host=192....', 'root', 'password', Array) #1 /usr/share/php/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect() #2 /usr/share/php/Zend/Db/Adapter/Abstract.php(448): Zend_Db_Adapter_Pdo_Mysql->_connect() #3 /usr/share/php/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('DESCRIBE
bny_c...', Array) #4 /usr/share/php/Zend/Db/Adapter/Pdo/Mysql.php(156): Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBEbny_c...') #5 /usr/share/php/Zend/Db/Table/Abstract.php(823): Zend_Db_Adapter_Pdo_Mysql->describeTable('bny_core_module...', NULL) #6 /usr/share/php/Zend/Db/Table/Abstract.php(866): Zend_Db_Table_Abstract->_setupMetadata() #7 /usr/share/php/Zend/Db/Table/Abstract. in /usr/share/php/Zend/Db/Adapter/Pdo/Abstract.php on line 144
Please help me to resolve this problem.
Last time I had this type of error, I had to change my host from: 127.0.0.1 to 'localhost' and then it worked fine.
這篇關(guān)于“與 MySQL 服務(wù)器的連接丟失"嘗試連接到遠(yuǎn)程 MySQL 服務(wù)器時的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!