I'm aware this is a repeat question, but none of the solutions online seem to be working for me.
I'm trying to add authentication to a laravel 5 project (using make:auth
)
Whenever I try to 'register', I get a SQLSTATE[HY000] [2002] Connection refused
error.
The responses online have been to change localhost to 127.0.0.1 and vise-vera, but that isn't working for me.
Any idea anyone? Thanks (I'm on OSX, if that makes a difference at all)
.env
DB_HOST=localhost
DB_DATABASE=test
DB_USERNAME=test
DB_PASSWORD=
database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'test'),
'username' => env('DB_USERNAME', 'test'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
If you are using MAMP be sure to add the unix_socket key with a value of the path that the mysql.sock resides in MAMP.
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
'database' => 'database',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),