I'm aware this can be a recurring question, but none of the solutions i found online seem to be working with my problem.
I have a Laravel 5.8 project but i can't access to my database from a controller, all artisan command works fine (like php artisan migrate)
But when a try a simple thing like:
protected function test()
{
return User::all();
}
I get SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `users` where `users`.`deleted_at` is null)
I simply trying to access my local database (from OSX) My Config :
.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=root
DB_PASSWORD=secret
database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'database'),
'username' => env('DB_USERNAME', 'database'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
],
My database is working (i can access it with an IDE or else)
Thanks for your help !