I have a problem with my Laravel project. I started it a few hours ago but I'm stuck with an SQL error :
SQLSTATE[HY000] [2002] Connection refused
I've searched for hours now and I only found it would be wrong password or wrong port but I checked and it's fine for me.
Here's the .env file :
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3302
DB_DATABASE=test_technique
DB_USERNAME=root
DB_PASSWORD=
Here's the .env.example file :
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3302
DB_DATABASE=test_technique
DB_USERNAME=root
DB_PASSWORD=
And here's the database.php :
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3302'),
'database' => env('DB_DATABASE', 'test_technique'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
And to check the port of mysql :
Test for TCP
Your port 3302 is used by a processus with PID = 2292
The processus of PID 2292 is 'mysqld.exe' Session: Services
The service of PID 2292 for 'mysqld.exe' is 'N/A'
N/A means that there are no service related to PID 2292
Processus 'mysqld.exe' is launched by service 'wampmysqld64' with PID 5048
Test for TCPv6
Your port 3302 is used by a processus with PID = 2292
The processus of PID 2292 is 'mysqld.exe' Session: Services
The service of PID 2292 for 'mysqld.exe' is 'N/A'
N/A means that there are no service related to PID 2292
Processus 'mysqld.exe' is launched by service 'wampmysqld64' with PID 5048
I've never changed the USERNAME and PASSWORD in mysql so I don't know why there's this error
P.S : In another site, when I use PDO like this, it works :
new PDO("mysql:host=localhost:3302;dbname=test_technique;charset=utf8", "root", "",array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
mysql -u root --port=3302. If you cannot, then you'll need to change the configuration of mysql. Though I'm curious what's running on 3306 that isn't mysql. - aynber