Prerequisites
- The EC2 instance and the RDS database have already been set up.
- The EC2 instance and the RDS database belong to the same security group and have the same VPC ID.
- An app has already been deployed on Elastic Beanstalk.
- SSH connection to the EC2 instance is enabled.
After accessing the EC2 instance via SSH, we can connect to the database as below. Enter the password, and you should be able to connect to your mysql database.
// connect to EC2 instance
$ ssh -i "KEYPAIR_PEMFILE.pem" ec2-user@PUBLIC_DNS.compute-1.amazonaws.com
// connect to mysql
[ec2-user@PUBLIC_DNS ~]$ mysql -h RDS_ENDPOINT.us-east-1.rds.amazonaws.com -P 3306 -u ADMIN_NAME -p
password:
Once you enter, you can use mysql commands to navigate through the database. If you want to check the database contents of your Elastic Beanstalk, you can select ebdb
.
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ebdb |
| innodb |
| mysql |
| performance_schema |
| sys |
| tmp |
+--------------------+
// to check contents of your Elastic Beanstalk database
MySQL [(none)]> use ebdb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MySQL [ebdb]> show tables;
+-----------------------------+
| Tables_in_ebdb |
+-----------------------------+
| auth_group |
| auth_group_permissions |
| auth_permission |
| django_admin_log |
| django_content_type |
| django_migrations |
| django_session |
+-----------------------------+
Top comments (0)