Reputation: 46
I am using MAMP PRO local server with configured PHP 7.1 and mysql 5.6.38. Install Laravel 5.6 using composer and edit .env file as the following,
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=sample
DB_USERNAME=root
DB_PASSWORD=root
and run command PHP artisan make:auth
.
When I tried to log in, it returns SQLSTATE[HY000] [2002] Connection refused
.
I have changed DB_HOST=127.0.0.1
. Still, it returns the same.
Thanks in Advance
Upvotes: 2
Views: 5507
Reputation:
Try adding the MySQL port to your database.php:
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306')
Check one of the following things otherwise:
( Point 3 can be done with adding the following code to your database.php)
'mysql' => array (
'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock')
)
Upvotes: 8