Create a RDS MySQL database and use MySQL workbench to create a database and
also insert tables with content inside it. And perform mysql queries to manipulate the
data inside it.
Open the AWS Management Console in a new browser window, so you can keep this
step-by-step guide open. When the console opens, select Database from the left
navigation pane and choose RDS to open the Amazon RDS console.
In the Create database section, choose Create database.
You now have options to select your engine. For this tutorial, choose the MySQL
icon, leave the default value of edition and engine version, and select the Free Tier
template.
You will now configure your DB instance. The list below shows the example
settings you can use for this tutorial:
Settings:
● DB instance identifier: Type a name for the DB instance that is unique for your
account in the Region that you selected. For this tutorial, we will name it rds-
mysql-10minTutorial.
● Master username: Type a username that you will use to log in to your DB instance.
We will use masterUsername in this example.
● Master password: Type a password that contains from 8 to 41 printable ASCII
characters (excluding /,", and @) for your master user password.
● Confirm password: Retype your password
You are now in the Connectivity section where you can provide information that
Amazon RDS needs to launch your MySQL DB instance. The list below shows
settings for our example DB instance.
Connectivity
● Compute resource: Choose Don’t connect to an EC2 compute resource. You can
manually set up a connection to a compute resource later.
● Virtual Private Cloud (VPC): Select Default VPC.
Amazon RDS supports several ways to authenticate database users. Choose
Password authentication from the list of options.
Monitoring
● Enhanced monitoring: Leave Enable enhanced monitoring unchecked to stay within
the Free Tier. Enabling enhanced monitoring will give you metrics in real time for the
operating system (OS) that your DB instance runs on.
In the Additional configurations section:
Database options
● Database name: Enter a database name that is 1 to 64 alphanumeric characters. If
you do not provide a name, Amazon RDS will not automatically create a database
on the DB instance you are creating.
● DB parameter group: Leave the default value.
● Option group: Leave the default value.
Backup
● Backup retention period: You can choose the number of days to retain the backup you
take. For this tutorial, set this value to 1 day.
● Backup window: Use the default of No preference.
Maintenance
● Auto minor version upgrade: Select Enable auto minor version upgrade to receive
automatic updates when they become available.
● Maintenance Window: Select No preference.
Deletion protection: Turn off Enable deletion protection for this tutorial. When this option is
enabled, you're prevented from accidentally deleting the database.
Choose Create Database.
Your DB instance is now being created.
Note: Depending on the DB instance class and storage allocated, it could take several
minutes for the new DB instance to become available.
The new DB instance appears in the list of DB instances on the RDS console. The DB
instance will have a status of creating until the DB instance is created and ready for use.
When the state changes to available, you can connect to a database on the DB instance.
Feel free to move on to the next step as you wait for the DB instance to become available.
Once the database instance creation is complete and the status changes to available, you
can connect to a database on the DB instance using any standard SQL client. In this step, we
will download MySQL Workbench, which is a popular SQL client.
a. Go to the Download MySQL Workbench page to download and install MySQL
Workbench. For more information on using MySQL, see the MySQL Documentation.
Connect to the Database:
In this step, we will connect to the database you created using MySQL Workbench.
a. Launch the MySQL Workbench application and go to Database > Connect to Database
(Ctrl+U) from the menu bar.
b. A dialog box appears. Enter the following:
● Hostname: You can find your hostname on the Amazon RDS console. Below
connectivity and security you will find the endpoint and port. Copy that and paste.
● Port: The default value should be 3306.
● Username: Type in the username you created for the Amazon RDS database. In this
tutorial, it is 'admin’
● Password: Choose Store in Vault (or Store in Keychain on MacOS) and enter the
password that you used when creating the Amazon RDS database.
Choose OK.
Create table in workbench:
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
email VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Remove this and now insert users into the users table:
INSERT INTO users (username, email) VALUES
('john_doe', '[email protected]'),
('alice_smith', '[email protected]'),
('bob_jackson', '[email protected]');
Delete the DATABASE:
You can easily delete the MySQL DB instance from the Amazon RDS console. It is a
best practice to delete instances that you are no longer using so that you don’t keep
getting charged for them.
a. Go back to the Amazon RDS console. Select Databases, choose the instance that you
want to delete, and then select Delete from the Actions dropdown menu.
b. You are asked to create a final snapshot and to confirm the deletion.
For our example, do not create a final snapshot, acknowledge that you
want to delete the
instance, and then choose Delete.