I have hosted a site in AWS. I have created a RDS DB instance for the elastic beanstalk. In my laravel app's config/database.php file, I have configured my database connection as :
'mysql' => [
'driver' => 'mysql',
'host' => 'mydbidentefier.cdh7pykyg7in.ap-south-1.rds.amazonaws.com',
'port' => 3306,
'database' => 'mydbidentefier',
'username' => 'admin',
'password' => 'mypw',
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
Now when I try to run php artisan migrate
by SSHing into the EC2 instance, I get this error :
SQLSTATE[HY000] [1049] Unknown database 'mydbindentifier' (SQL: select * from
projects
)
The "mydbidentifier" is the DB identifier that is shown in the RDS console. How can that not be found.
One more thing : Should I not be able to run mysql from the command line by SSHing into the EC2 instance ? When I try mysql -u root -p
by SSHing into the EC2 command line terminal. I get another error :
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Am I missing anything? Any guidance would be highly appreciated.