Course Content
Introduction to Cloud Computing
Introduction to Cloud Computing
Connecting to the RDS from EC2 Instance
To connect to the database from an EC2 instance, we need to perform the same actions as when connecting to a database from any Linux computer.
You'll learn how to connect from your Linux instance to the cloud database and use SQL queries to retrieve, create, modify, and delete data in the database. In the end, you'll have full access and control over the database.
Install MySQL
You need to install MySQL on your instance. Use the following commands:
This command grants us superuser privileges and also updates components if they haven't been updated on our system.
Next, we need to install the MariaDB server, which will contain the MySQL server we need. You can do this with the following command:
After a successful installation, we can connect to our database instance using the following command:
Performing operations using SQL.
Now that we've successfully connected to the database via MySQL, we can begin performing operations on our databases and tables.
To start, let's use the following command to check if everything is correct and if we're connected to the right database:
To run a command in this console, you need to use a semicolon at the end. Otherwise, you'll simply move to the next line. This is quite handy for writing and organizing large queries, but be cautious with it.
Next, let's select the database we created to start working with the tables inside it using a simple command:
Now we can write a regular SQL query here and fetch some data from any table.
For instance, let's check out the user_phones
table:
We retrieved information from the table that we created locally through MySQL Workbench. This demonstrates that our database is in the cloud and that there's absolutely nothing difficult about using RDS.
Thanks for your feedback!