I have updated a Laravel 5.5-installation to 5.8 and am now attempting to update the MySQL-installation from 5.7 to 8.0.19. The Laravel-installation is on an EC2-instance and works great with the previous RDS MySQL/Aurora installation, but the version did not cut it.
We are running this on an nginx-server.
First I got an error-message stating
(2/2) PDOException
SQLSTATE[HY000] [2002] Connection refused
Tried to change the AWS uri and use the ip instead, and got a 504 instead.
I tried to access the database through MySQL Workbench and through new PDO('mysql:host=xx-rds-staging-mysql-8.xxxxxxxxxxxx.eu-west-1.rds.amazonaws.com;port=3306;dbname=database', 'username', 'password', [0, 2, 0, false, false, false])
and... they both work perfectly from the EC2-instance.
Env-file:
DB_CONNECTION="mysql"
DB_HOST_WRITE="xx-rds-staging-mysql-8.xxxxxxxxxxxx.eu-west-1.rds.amazonaws.com"
DB_HOST_READ="xx-rds-staging-mysql-8.xxxxxxxxxxxx.eu-west-1.rds.amazonaws.com"
DB_PORT_READ_AND_WRITE="3306"
DB_DATABASE="database"
DB_USERNAME="username"
DB_PASSWORD="password"
config/database.php
'mysql' => [
'read' => [
'host' => env('DB_HOST_READ', '127.0.0.1'),
],
'write' => [
'host' => env('DB_HOST_WRITE', '127.0.0.1'),
],
'port' => env('DB_PORT_READ_AND_WRITE', '3306'),
'driver' => 'mysql',
'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' => '',
'strict' => false,
'engine' => null,
'sticky' => true,
'version' => 8,
'modes' => [
#'ONLY_FULL_GROUP_BY',
'STRICT_TRANS_TABLES',
'NO_ZERO_IN_DATE',
'NO_ZERO_DATE',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_ENGINE_SUBSTITUTION',
],
'options' => [
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
],
],
I have cleared the cache by all the artisan-commands and by deleting the cache-folder.
I am rubbish at asking for help here, not ever certain what information I need to share to make my case.
My first thought is that there ought to be some setting in Laravel which I could swap to make this work, but I have no idea what it could be.
The mysql-server does not run on the same machine as the laravel-application and AWS has not offered a public ip, just the uri.
What makes it even stranger is that I can enter php artisan tinker
and run, for example, User::first();
and it will fetch the appropriate row from the database, without any issue.