mysql - SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known -
i download https://github.com/luciddreamz/laravel laravel openshift upload on repository on github . code connect database not work. problem load variable .env
file locate in root of project
for solve problem change.env
# local environment # production, see .openshift/.env app_env=application_env app_debug=true app_url=openshift_app_dns app_key=openshift_secret_token db_driver=mysql db_host=openshift_mysql_db_host db_port=openshift_mysql_db_port db_database=openshift_app_name db_username=openshift_mysql_db_username db_password=openshift_mysql_db_password cache_driver=apc session_driver=file
my error :sqlstate[hy000] [2002] php_network_getaddresses: getaddrinfo failed: name or service not known
createconnection('mysql:host=openshift_mysql_db_host;port=openshift_mysql_db_port;dbname=openshift_app_name', array('driver' => 'mysql', 'host' => 'openshift_mysql_db_host', 'port' => 'openshift_mysql_db_port', 'database' => 'openshift_app_name', 'username' => 'openshift_mysql_db_username', 'password' => 'openshift_mysql_db_password', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, '0')) in mysqlconnector.php line 20
first line of error message describes error type: "pdoexception". next line displays pdo::errorinfo
, i.e:
- sqlstate error code (a 5 characters alphanumeric identifier defined in ansi sql standard).
- driver-specific error code.
- driver-specific error message.
- "hy000" general server error (see server error codes , messages in mysql docs).
- "2002" mysql client error code meaning "can't connect local mysql server through socket" (see (client error codes , messages in mysql docs).
- the driver specific error code , message ("php_network_getaddresses: getaddrinfo failed: name or service not known") tell pdo not able resolve host name.
the stack trace attached, line 3, reveals did not specify database connection parameters in configuration file. error show when test on local, right? need update /.env
actual database connection parameters.
Comments
Post a Comment