Reputation: 394
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_',
),
Upvotes: 1
Views: 1770
Reputation: 439
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.
Upvotes: 1