我正在尝试连接到mysql和sqlserver数据库,但出现此错误:
我正在使用nginx,并且可以与php正常连接,我在使用cakephp 3时遇到此错误。
2019-09-24 14:29:34 Error: [PDOException] SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: unknown name or service
#0 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/Database/Driver.php(92): PDO->__construct('mysql:host=devs...', 'desarrollo', 'holalaparis', Array)
#1 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php(106): Cake\Database\Driver->_connect('mysql:host=devs...', Array)
#2 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/Database/Schema/BaseSchema.php(45): Cake\Database\Driver\Mysql->connect()
#3 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/Database/Dialect/MysqlDialectTrait.php(63): Cake\Database\Schema\BaseSchema->__construct(Object(Cake\Database\Driver\Mysql))
#4 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/Database/Schema/Collection.php(52): Cake\Database\Driver\Mysql->schemaDialect()
#5 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/Database/Schema/CachedCollection.php(42): Cake\Database\Schema\Collection->__construct(Object(Cake\Database\Connection))
#6 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/Database/Connection.php(391): Cake\Database\Schema\CachedCollection->__construct(Object(Cake\Database\Connection), true)
#7 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/ORM/Table.php(559): Cake\Database\Connection->getSchemaCollection()
#8 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/ORM/Query.php(269): Cake\ORM\Table->getSchema()
#9 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/ORM/Query.php(167): Cake\ORM\Query->addDefaultTypes(Object(Cake\ORM\Table))
#10 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/ORM/Table.php(1769): Cake\ORM\Query->__construct(Object(Cake\Database\Connection), Object(Cake\ORM\Table))
#11 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/ORM/Table.php(1362): Cake\ORM\Table->query()
#12 /usr/share/nginx/html/my_web/src/Controller/PagesController.php(280): Cake\ORM\Table->find()
#13 /usr/share/nginx/html/my_web/src/Controller/PagesController.php(23): App\Controller\PagesController->defJuegos()
#14 /usr/share/nginx/html/my_web/vendor/cakephp/cakephp/src/Controller/Controller.php(273): App\Controller\PagesController->initialize()
答案 0 :(得分:0)
问题解决了! 无法识别主机名,将IP设置为有效