MySQL connection over SSL with Laravel
I finally solved the issue. The config above is actually good. I was working in the docker container directly. For some reason the config kept in cache.
Following commands did not clear the config cache:
php artisan config:clearphp artisan config:cachephp artisan cache:clear
I noticed this when I created a new user to connect with the database to test something. I rebuild the container with the new config and everything works perfectly now.
Please check your .env file. This file will be on website root folder.
DB_CONNECTION=mysqlDB_HOST=hostipDB_PORT=3306DB_DATABASE=database_nameDB_USERNAME=database_user_nameDB_PASSWORD=database_password
2.also update config -> database.php file as:
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'sslmode' => env('DB_SSLMODE', 'prefer'), 'options' => array( PDO::MYSQL_ATTR_SSL_CA => '/home/.../ca-cert.pem', PDO::MYSQL_ATTR_SSL_CERT => '/home/.../cert.pem', PDO::MYSQL_ATTR_SSL_KEY => '/home/.../key.pem' ), 'strict' => true, 'engine' => null, ],