Hi I am new to laravel in my app when i connecting database i got following error
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
public function createConnection($dsn, array $config, array $options)
{
$username = array_get($config, 'username');
$password = array_get($config, 'password');
**return new PDO($dsn, $username, $password, $options);**
}
'mysql' => array(
'driver' => 'mysql',
'host' => 'HOST NAME',
'port' => '3306',
'database' => 'DBNAME',
'username' => 'DBUSER',
'password' => 'DBPASSWORD',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'vox_',
),
This might be pretty obvious, but
'host' => 'HOST NAME',
'port' => '3306',
'database' => 'DBNAME',
'username' => 'DBUSER',
'password' => 'DBPASSWORD',
those are set to strings HOST NAME, DBNAME, etc. hardcode your DB credentials and see if it works.
尝试用IP地址替换主机名
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.