Create and Connect to MySQL Database with Amazon RDS

In this tutorial, you will learn how to create an environment to run your MySQL database (we call this environment an ‘instance’), connect to the database, and delete the DB instance.  We will do this using Amazon Relational Database Service (Amazon RDS) and everything done in this tutorial is free-tier eligible.
When you click here, the AWS management console will open in a new browser window, so you can keep this step-by-step guide open. When this screen loads, find RDS under Database and click to open the Amazon RDS Console.
rds-1
Step 1: Create a MySQL DB Instance
In this step, we will use Amazon RDS to create a MySQL DB Instance with db.t2.micro DB instance class, 5 GB of storage, and automated backups enabled with a retention period of one day. As a reminder, all of this is free tier eligible.
rds-2-location
b. In the navigation pane on the left, click Instances. Then click Launch DB Instance.
rds-3-instances
c. You now have options to select your engine. For this tutorial, click the MySQL icon and then click Select.
rds-5-selectMySQL
d. The next screen gives you options to choose your environment. Select the MySQL option under Dev/Test and click Next Step.
rds-6-devtest
e. You will now configure your DB instance. The list below shows the example settings you can use for this tutorial:
rds-9-form
Instance Specifications:
License Model: Select the default general-public-license to use the general license agreement for MySQL. MySQL has only one license model.
DB Engine Version: Select the default version of MySQL. Note that Amazon RDS supports multiple versions of MySQL in some Regions.
DB Instance Class: Select db.t2.micro — 1vCPU, 1 GIB RAM. This equates to 1 GB memory and 1 vCPU. To see a list of supported instance classes, see Amazon RDS Product Details.
Multi-AZ Deployment: Select No to create your DB instance in a single Availability Zone for this tutorial. Using a Multi-AZ Deployment will automatically provision and maintain a synchronous standby replica in a different Availability Zone. Note that you will have to pay for Multi-AZ Deployment. For more information, see High Availability Deployment.
Storage Type: Select General Purpose (SSD). For more information about storage, see Storage for Amazon RDS.
Allocated Storage: Type 5 to allocate 5 GB of storage for your database. You can scale up to a maximum of 6 TB with Amazon RDS for MySQL.
Settings:
DB Instance Modifier: Type a name for the DB instance that is unique for your account in the Region 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.
Click Next Step
f. You are now on the Configure Advanced Settings page where you can provide additional information that RDS needs to launch the MySQL DB instance. The list below shows settings for our example DB instance.
Untitled-1
Network & Security
VPC: Select Default VPC. For more information about VPC, see Amazon RDS and Amazon Virtual Private Cloud (VPC).
Subnet Group: Choose the default subnet group. For more information about subnet groups, see Working with DB Subnet Groups.
Publicly Accessible: Choose Yes. This will allocate an IP address for your database instance so you can directly connect to the database from your own device.
Availability Zone: Choose No Preference. See Regions and Availability Zones for more details.
VPC Security Group(s): Select Create New Security Group. This will create a security group that will allow connection from the IP address of the device you are currently using, to the database created.
Database Options
Database Name: Type a database name that is 1 to 64 alpha-numeric characters. If you do not provide a name, Amazon RDS will not automatically create a database on the DB instance you are creating.
Database Port: Leave the default value of 3306.
DB Parameter Group: Leave the default value of default.mysql5.6. For more information, see Working with DB Parameter Groups.
Option Group: Select the default value of default:mysql5.6. Amazon RDS uses option groups to enable and configure additional features. For more information, see Working with Option Groups.
Enable Encryption: For this task, select No to disable encryption. For more information, see Encrypting Amazon RDS Resources.
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.
Backup Window: Use the default of No Preference.
Monitoring
Enable Enhanced Monitoring: Use the default of No 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. For more information, see Viewing DB Instance Metrics.
Maintenance
Auto Minor Version Upgrade: Select Yes to receive automatic updates when they become available.
Maintenance Window: Select No Preference.
Click Launch DB Instance
g. Your DB Instance is now being created. Click View Your DB Instance
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.
rds-11-dbcreated
Step 2: Download a SQL Client
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.
Step 3: Connect to the MySQL Database

b. A dialogue box appears. Enter the following:
Hostname: You can find your hostname on the Amazon RDS console as shown in the screenshot to the right.
Port: The default value should be 3306.
Username: Type in the username you created for the Amazon RDS database. Our example was ‘masterUsername.’
Password: Click Store in Vault and enter the password you used while creating the Amazon RDS database.
Click OK

Be the first to comment

Leave a Reply

Your email address will not be published.


*