I'm having trouble getting Laravel to connect to an AWS RDS Aurora instance. The VPC security groups are set correctly to allow inbound and outbound on port 3306 from the internal web server. After connecting to the web server through the bastion host, I can successfully run the following command: mysql -u user -pPass -h XXXX.amazonaws.com database and it connects to the instance just fine. This also tells me that VPC security groups are set correctly, I believe.
This is running on
- CentOS release 6.8 (Final)
- PHP: 5.6.22 (cli)
- Fresh install of Laravel 5.2
- PHP MySQL drivers installed using
sudo yum install php53-mysqlsudo yum install php-mysqlisudo yum install php56w-pdo
Laravel is running fine and accessible through an external IP, but it cannot connect to the database. When I try to run php artisan migrate to get the migrations, users, and password_resets tables into the database, I get the following error:
[PDOException]
SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 111
I also get this error when trying to connect through MySQL Workbench using an SSH tunnel through the bastion host (although, I don't have an SSH Key File, which could be the problem there). It's more important I get this working in Laravel, although help with MySQL Workbench is also greatly appreciated.
Laravel files:
.env
DB_HOST=XXXX.amazonaws.com
DB_DATABASE=database
DB_USERNAME=user
DB_PASSWORD=Pass
config/database.php
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'XXXX.amazonaws.com'),
'port' => '3306',
'database' => env('DB_DATABASE', 'database'),
'username' => env('DB_USERNAME', 'user'),
'password' => env('DB_PASSWORD', 'Pass'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
//'engine' => null,
],
],
Aucun commentaire:
Enregistrer un commentaire