Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Connecting to the RDS from EC2 Instance | RDS Management
Introduction to Cloud Computing
course content

Course Content

Introduction to Cloud Computing

Introduction to Cloud Computing

1. Introduction to Cloud Technologies
2. AWS S3 Overview
3. EC2 Overview
4. RDS Management

bookConnecting to the RDS from EC2 Instance

I think you're interested in how to connect from our instance to the database. There's nothing complicated about it, and I'll show you how to do it in this chapter!

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.

Note

As a reminder, EC2 is simply a rented computer with a Linux operating system installed, so there's nothing special about it.

This chapter will demonstrate how to connect from your Linux instance to the cloud database and use SQL queries to retrieve, create, modify, and delete information in the database. Overall, you'll gain full access and control over the database.

Let's get started!

Install MySQL

First, you need to install MySQL on your instance. Use the following commands:

This command makes us a superuser and also updates components if they haven't been updated on our system.

Next, we need to install the MariaDB server, inside which will be the MySQL server we need. This is done with the following command:

After successful installation, we can connect to our database instance using the following command:

Note

When prompted for your password, none of the keys you press will be displayed. You need to type your password on the keyboard and press enter.

Performing operations using SQL.

Now that we've successfully connected to the database via MySQL, we can start performing operations on our databases and tables.

To start, let's use the following command to verify that we've entered everything correctly and connected to the correct database:

To execute a command in such a console, you need to use a semicolon at the end. Otherwise, you'll just move to the next line. This is very convenient for writing and structuring large queries, but be careful with it.

Next, let's select the database we created to start working with the tables in it using a simple command;

Great, now we can write a regular SQL query here and retrieve some data from any table.

For example, let's take a look at the user_phones table:

Great! We retrieved information from the table that we created locally through MySQL Workbench. This shows us that our database is in the cloud and that there is absolutely nothing difficult about using RDS.

Creating and managing a database in the cloud is a very good outcome!

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 5
some-alt