Creating a DB Cluster and Connecting to a Database on an Aurora MySQL DB Cluster - Amazon Aurora

Creating a DB Cluster and Connecting to a Database on an Aurora MySQL DB Cluster

The easiest way to create an Aurora MySQL DB cluster is to use the Amazon RDS console. After you create the DB cluster, you can use standard MySQL utilities, such as MySQL Workbench, to connect to a database on the DB cluster.

Create an Aurora MySQL DB Cluster

Before you create a DB cluster, you must first have a virtual private cloud (VPC) based on the Amazon VPC service and an Amazon RDS DB subnet group. Your VPC must have at least one subnet in each of at least two Availability Zones. You can use the default VPC for your AWS account, or you can create your own VPC. The Amazon RDS console makes it easy for you to create your own VPC for use with Amazon Aurora or use an existing VPC with your Aurora DB cluster.

If you want to create a VPC and DB subnet group for use with your Aurora DB cluster yourself, rather than having Amazon RDS create the VPC and DB subnet group for you, then follow the instructions in How to Create a VPC for Use with Amazon Aurora. Otherwise, follow the instructions in this topic to create your DB cluster and have Amazon RDS create a VPC and DB subnet group for you.

Note

A new console interface is available for database creation. Choose either the New Console or the Original Console instructions based on the console that you are using. The New Console instructions are open by default.

You can create an Aurora with MySQL compatibility DB cluster with the AWS Management Console with Easy Create enabled or disabled. With Easy Create enabled, you specify only the DB engine type, DB instance size, and DB instance identifier. Easy Create uses the default setting for other configuration options. With Easy Create disabled, you specify more configuration options when you create a database, including ones for availability, security, backups, and maintenance.

Note

For this example, Easy Create is enabled. For information about creating an Aurora MySQL DB cluster with Easy Create not enabled, see Creating an Amazon Aurora DB Cluster.

To create an Aurora MySQL DB cluster with Easy Create enabled

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

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

    Aurora is not available in all AWS Regions. For a list of AWS Regions where Aurora is available, see Region Availability.

  3. In the navigation pane, choose Databases.

  4. Choose Create database and make sure that Easy Create is chosen.

    
							Easy Create option
  5. For Engine type, choose Amazon Aurora.

  6. For Edition, choose Amazon Aurora with MySQL 5.6 compatibility.

  7. For DB instance size, choose Dev/Test.

  8. For DB cluster identifier, enter a name for the DB cluster, or leave the default name.

  9. For Master username, enter a name for the master user, or leave the default name.

    The Create database page should look similar to the following image:

    
							Create database page
  10. To use an automatically generated master password for the DB cluster, make sure that the Auto generate a password is chosen.

    To enter your master password, clear the Auto generate a password check box, and then enter the same password in Master password and Confirm password.

  11. (Optional) Open View default settings for Easy create.

    
							Easy Create default settings.

    You can examine the default settings used when Easy Create is enabled. If you want to change one or more settings during database creation, choose Standard Create to set them. The Editable after database creation column shows which options you can change after database creation. To change a setting with No in that column, use Standard Create. For settings with Yes in that column, you can either use Standard Create or modify the DB instance after it's created to change the setting.

  12. Choose Create database.

    If you chose to use an automatically generated password, the View credential details button appears on the Databases page.

    To view the master user name and password for the DB instance, choose View credential details.

    
							Master user credentials after automatic password generation.

    To connect to the DB instance as the master user, use the user name and password that appear.

    Important

    You can't view the master user password again. If you don't record it, you might have to change it. If you need to change the master user password after the DB instance is available, you can modify the DB instance to do so. For more information about modifying a DB instance, see Modifying an Amazon Aurora DB Cluster.

  13. For Databases, choose the name of the new Aurora MySQL DB cluster.

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

    
							Summary during DB cluster creation

To launch an Aurora MySQL DB cluster

  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 AWS Management Console, choose the AWS Region that you want to create your DB cluster in. For a list of AWS Regions where Aurora is available, see Region Availability.

  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 to open the Select engine page.

  5. On the Select engine page, choose Amazon Aurora and choose the MySQL-compatible edition.

    
							Amazon Aurora Select engine page
  6. Choose Next.

  7. Set the following values on the Specify DB details page:

    • DB instance class: db.r4.large

    • DB instance identifier: gs-db-instance1

    • Master username: Using alphanumeric characters, type a master user name, used to log on to your DB instances in the DB cluster.

    • Master password and Confirm Password: Type a password in the Master Password box that contains from 8 to 41 printable ASCII characters (excluding /,", and @) for your master user password, used to log on to your database. Then type the password again in the Confirm Password box.

    
							Specify DB details page
  8. Choose Next and set the following values on the Configure Advanced Settings page:

    • Virtual Private Cloud (VPC): If you have an existing VPC, then you can use that VPC with your Amazon Aurora DB cluster by choosing your VPC identifier, for example vpc-a464d1c1. For information on using an existing VPC, see How to Create a VPC for Use with Amazon Aurora.

      Otherwise, you can choose to have Amazon RDS create a VPC for you by choosing Create a new VPC. This example uses the Create a new VPC option.

    • Subnet group: If you have an existing subnet group, then you can use that subnet group with your Amazon Aurora DB cluster by choosing your subnet group identifier, for example, gs-subnet-group1.

      Otherwise, you can choose to have Amazon RDS create a subnet group for you by choosing Create a new subnet group. This example uses the Create a new subnet group option.

    • Public accessibility: Yes

      Note

      Your production DB cluster might not need to be in a public subnet, because only your application servers require access to your DB cluster. If your DB cluster doesn't need to be in a public subnet, set Publicly Accessible to No.

    • Availability zone: No Preference

    • VPC security groups: If you have one or more existing VPC security groups, then you can use one or more of those VPC security groups with your Amazon Aurora DB cluster by choosing your VPC security group identifiers, for example, gs-security-group1.

      Otherwise, you can choose to have Amazon RDS create a VPC security group for you by choosing Create new VPC security group. This example uses the Create new VPC security group option.

    • DB cluster identifier: gs-db-cluster1

    • Database name: sampledb

      Note

      This creates the default database. To create additional databases, connect to the DB cluster and use the SQL command CREATE DATABASE.

    • Database port: 3306

      Note

      You might be behind a corporate firewall that does not allow access to default ports such as the Aurora MySQL default port, 3306. In this case, provide a port value that your corporate firewall allows. Remember that port value later when you connect to the Aurora DB cluster.

  9. Leave the rest of the values as their defaults, and choose Create database to create the DB cluster and primary instance.

Connect to an Instance in a DB Cluster

Once Amazon RDS provisions your DB cluster and creates the primary instance, you can use any standard SQL client application to connect to a database on the DB cluster. In this example, you connect to a database on the Aurora MySQL DB cluster using MySQL monitor commands. One GUI-based application that you can use to connect is MySQL Workbench. For more information, go to the Download MySQL Workbench page.

To connect to a database on an Aurora MySQL DB cluster using the MySQL monitor

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

  2. Choose Databases and then choose the DB cluster name to show its details. On the Connectivity & security tab, copy the value for the Endpoint name of the Writer endpoint. Also, note the port number for the endpoint.

    
							DB Cluster Details
  3. Type the following command at a command prompt on a client computer to connect to a database on an Aurora MySQL DB cluster using the MySQL monitor. Use the cluster endpoint to connect to the primary instance, and the master user name that you created previously. (You are prompted for a password.) If you supplied a port value other than 3306, use that for the -P parameter instead.

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

    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.10-log MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>

For more information about connecting to the DB cluster, see Connecting to an Amazon Aurora MySQL DB Cluster.

Delete the Sample DB Cluster, DB Subnet Group, and VPC

Once you have connected to the sample DB cluster that you created, you can delete the DB cluster, DB subnet group, and VPC (if you created a VPC).

To delete a DB cluster

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

  2. Choose Databases and then choose the DB instance associated with the DB cluster.

  3. For Actions, choose Delete.

  4. Choose Delete.

    After all of the DB instances associated with a DB cluster are deleted, the DB cluster is deleted automatically.

To delete a DB subnet group

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

  2. Choose Subnet groups and then choose the DB subnet group.

  3. Choose Delete.

  4. Choose Delete.

To delete a VPC

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

  2. Choose Your VPCs and then choose the VPC that was created for this procedure.

  3. For Actions, choose Delete VPC.

  4. Choose Delete.