"Lost connection to MySQL server" when trying to connect to a remote MySQL server

I am using the Zend Framework to develop my application, and I am trying to connect to a remote MySQL database on my local network.

Database Connection Settings in Zend:

  [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 (' 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. in /usr/share/php/Zend/Db/Adapter/Pdo/Abstract.php on line 144 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. in /usr/share/php/Zend/Db/Adapter/Pdo/Abstract.php on line 144

Please help me solve this problem.

+4
source share
4 answers

The last time I had this type of error, I had to change my host: 127.0.0.1 to localhost ", and then it worked fine.

+7
source

I had the same problem to solve this problem. I changed the remote port in the tunnel configuration from 'localhost:3306' to '127.0.0.1:3306'.

On the target machine, localhost allowed :: 1, but MariaDB did not listen for IPv6 requests ...

0
source

This error means that you are connecting to the wrong server or the firewall has blocked it or the server is not working.

You need to contact the server administrator to confirm the correct data.

On most servers, you will use 127.0.0.1 , but some will use localhost , while others (such as a media temple) will need a fully qualified domain name - for example, internal-db.s421234.gridserver.com

0
source

Source: https://habr.com/ru/post/1332898/


All Articles