Amazon Relational Database Service
User Guide (API Version 2014-10-31)

Creating a MySQL DB Instance and Connecting to a Database on a MySQL DB Instance

The easiest way to create a DB instance is to use the AWS Management Console. Once you have created the DB instance, you can use standard MySQL utilities such as MySQL Workbench to connect to a database on the DB instance.

Important

You must complete the tasks in the Setting Up for Amazon RDS section before you can create or connect to a DB instance.

Creating a MySQL DB Instance

The basic building block of Amazon RDS is the DB instance. This is the environment in which you run your MySQL databases.

In this example, you create a DB instance running the MySQL database engine called mysql-instance1, with a db.m1.small DB instance class, 20 GiB of storage, and automated backups enabled with a retention period of one day.

To create a MySQL DB instance

  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the top right corner of the Amazon RDS console, choose the AWS Region in which you want to create the DB instance.

  3. In the navigation pane, choose Databases.

    If the navigation pane is closed, choose the menu icon at the top left to open it.

  4. Choose Create database. The Select engine page opens.

    
									Select engine
  5. Choose MySQL, and then choose Next.

  6. The Choose use case page asks if you are planning to use the DB instance you are creating for production. Choose Dev/Test and then choose Next.

  7. On the Specify DB Details page, specify your DB instance information. The following table shows settings for an example DB instance. When the settings are as you want them, choose Next.

    For This Parameter Do This

    License model

    Choose the default, general-public-license, to use the general license agreement for MySQL. MySQL has only one license model.

    DB engine version

    Choose the default version of MySQL. Amazon RDS supports multiple versions of MySQL in some AWS Regions.

    DB instance class

    Choose db.m1.small.

    Multi-AZ deployment

    Choose Yes to have a standby replica of your DB instance created in another Availability Zone for failover support. We recommend Multi-AZ for production workloads to maintain high availability. For development and testing, you can choose No.

    For more information, see High Availability (Multi-AZ) for Amazon RDS.

    Storage type

    Choose the storage type General Purpose (SSD). For more information about storage, see Amazon RDS DB Instance Storage.

    Allocated storage

    Enter 20 to allocate 20 GiB of storage for your database. In some cases, allocating a higher amount of storage for your DB instance than the size of your database can improve I/O performance. For more information about storage allocation, see Amazon RDS Features.

    DB instance identifier

    Enter a name for the DB instance that is unique for your account in the AWS Region you chose. You can add some intelligence to the name, such as including the AWS Region and DB engine you chose, for example mysql-instance1.

    Master username

    Enter a name using alphanumeric characters to use as the master user name to log on to your DB instance. This is the user name you use to log on to your database on the DB instance for the first time.

    Master password and Confirm password

    Enter a password that contains from 8 to 41 printable ASCII characters (excluding /,", and @) for your master user password. This is the password to use when you use the user name to log on to your database. Then type the password again in the Confirm Password box.

    
						DB instance details
  8. Choose Next.

  9. On the Configure advanced settings page, provide additional information that RDS needs to launch the MySQL DB instance. The table shows settings for an example DB instance. Specify your DB instance information, then choose Create database.

    For This Parameter Do This

    Virtual Private Cloud (VPC)

    Choose Create new VPC.

    Subnet group

    Choose Create new DB subnet group.

    Public accessibility

    Choose Yes.

    Availability zone

    Choose No Preference.

    VPC security groups

    Choose Create new VPC security group.

    Database name

    Enter a name for your default database that is 1 to 64 alpha-numeric characters. If you don't provide a name, Amazon RDS doesn't automatically create a database on the DB instance you are creating.

    To create additional databases, connect to the DB instance and use the SQL command CREATE DATABASE. For more information about connecting to the DB instance, see Connecting to a DB Instance Running the MySQL Database Engine.

    Database port

    Leave the default value of 3306 unless you have a specific port you want to access the database through. MySQL installations default to port 3306.

    DB parameter group

    Leave the default value unless you created your own DB parameter group. For more information about parameter groups, see Working with DB Parameter Groups.

    Option group

    Choose the default value because this option group is used with the MySQL version you chose on the previous page.

    Copy tags To snapshots

    Choose this option to have any DB instance tags copied to a DB snapshot when you create a snapshot. For more information, see Tagging Amazon RDS Resources.

    IAM DB authentication

    Choose No. For more information, see Identity and Access Management in Amazon RDS.

    Encryption

    Choose Enable encryption to enable encryption at rest for this DB instance. For more information, see Encrypting Amazon RDS Resources.

    Backup retention period

    Set the number of days you want automatic backups of your database to be retained. For testing purposes, you can set this value to 1.

    Backup window

    Unless you have a specific time that you want to have your database backup, use the default of No Preference.

    Enhanced monitoring

    Unless you want to enable gathering metrics in real time for the operating system that your DB instance runs on, use the default of Disable enhanced monitoring.

    Log exports

    Select General log. For more information, see MySQL Database Log Files.

    Auto minor version upgrade

    Choose Enable auto minor version upgrade to enable your DB instance to receive preferred minor DB engine version upgrades automatically when they become available.

    Maintenance window

    Choose No preference.

  10. Choose Create database.

  11. Choose View DB instance details.

    On the RDS console, the details for new DB instance appear. The DB instance has a status of creating until the DB instance is ready to use. When the state changes to available, you can connect to the DB instance. Depending on the DB instance class and the amount of storage, it can take up to 20 minutes before the new instance is available.

    
						My DB instances list

Connecting to a Database on a DB Instance Running the MySQL Database Engine

Once Amazon RDS provisions your DB instance, you can use any standard SQL client application to connect to a database on the DB instance. In this example, you connect to a database on a MySQL DB instance using MySQL monitor commands. One GUI-based application you can use to connect is MySQL Workbench; for more information, go to the Download MySQL Workbench page. For more information on using MySQL, go to the MySQL documentation. For information about installing MySQL (including the MySQL client), see Installing and Upgrading MySQL.

To connect to a database on a DB instance using MySQL monitor

  1. Find the endpoint (DNS name) and port number for your DB Instance.

    1. Open the RDS console and then choose Databases to display a list of your DB instances.

    2. Choose the MySQL DB instance name to display its details.

    3. On the Connectivity tab, copy the endpoint. Also, note the port number. You need both the endpoint and the port number to connect to the DB instance.

      
	            						Connect to a MySQL DB instance
  2. Download a SQL client that you can use to connect to the DB instance.

    You can connect to an Amazon RDS MySQL DB instance by using tools like the MySQL command line utility. For more information on using the MySQL client, go to mysql - The MySQL Command Line Tool in the MySQL documentation. One GUI-based application you can use to connect is MySQL Workbench. For more information, go to the Download MySQL Workbench page.

  3. Connect to the a database on a MySQL DB instance. For example, enter the following command at a command prompt on a client computer to connect to a database on a MySQL DB instance using the MySQL client. Substitute the DNS name for your DB instance for <endpoint>, the master user name you used for <mymasteruser>, and provide the master password you used when prompted for a password.

    PROMPT> mysql -h <endpoint> -P 3306 -u <mymasteruser> -p

    After you enter the password for the user, you should see output similar to the following.

    Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 350 Server version: 5.6.40-log MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>

If you can't connect to your MySQL DB instance, two common causes of connection failures to a new DB instance are:

  • The DB instance was created using a security group that does not authorize connections from the device or Amazon EC2 instance where the MySQL application or utility is running. If the DB instance was created in a VPC, it must have a VPC security group that authorizes the connections. If the DB instance was created outside of a VPC, it must have a DB security group that authorizes the connections. For more information, see Amazon Virtual Private Cloud VPCs and Amazon RDS.

  • The DB instance was created using the default port of 3306, and your company has firewall rules blocking connections to that port from devices in your company network. To fix this failure, recreate the instance with a different port.

For more information about connecting to a MySQL DB instance, see Connecting to a DB Instance Running the MySQL Database Engine.

Deleting a DB Instance

Once you have connected to the sample DB instance that you created, you should delete the DB instance so you are no longer charged for it.

To delete a DB instance with no final DB snapshot

  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Databases.

    If the navigation pane is closed, choose the menu icon at the top left to open it.

  3. Choose the DB instance you wish to delete.

  4. For Actions, choose Delete.

  5. For Create final snapshot?, choose No, and select the acknowledgment.

  6. Choose Delete.