参见英文答案 > How to connect a Laravel app to MySQL using MAMP?????????????????????????????????????1个
我在本地主机上收到Laravel 4.1的以下错误(使用MAMP)
SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (61)
它指向:
/Applications/MAMP/htdocs/crowdsets/laravel-master/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php
这是它指向的功能:
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);
}
到目前为止,我还没有收到此错误.
我设置了本地环境和生产环境(默认).
在config / local / database.php我有:
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'database',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),