嗨,当我连接数据库时,我在应用程序中对laravel不熟悉我遇到了以下错误
SQLSTATE [HY000] [2002] php_network_getaddresses:getaddrinfo失败:名称或服务未知
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_',
),
答案 0 :(得分:1)
这可能非常明显,但
'host' => 'HOST NAME',
'port' => '3306',
'database' => 'DBNAME',
'username' => 'DBUSER',
'password' => 'DBPASSWORD',
将这些设置为字符串HOST NAME,DBNAME等,对您的数据库凭据进行硬编码,看看它是否有效。
答案 1 :(得分:0)
尝试使用IP地址替换主机名