SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (SQL: SELECT * FROM users)
I want to connect to my remote database in my local project but when I do I get the error listed above. It works in my another database (from localhost), how can I connect my remote server database?
database.php
'mysql2' => [
'driver' => 'mysql',
'host' => 'domain.com',
'port' => '3306',
'database' => 'mybd',
'username' => 'username',
'password' => 'password',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'options' => ['mode' => 'ssl'],
'strict' => false,
'engine' => null,
]
Controller
public function test()
{
$users = DB::connection('mysql2')->select("SELECT * FROM users");
dd($users);
}