Amazon Relational Database Service
User Guide (API Version 2013-09-09)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Getting Started with Amazon RDS

This section shows you how to create and connect to a DB instance using Amazon RDS. A newly created DB instance has a firewall that prevents any access to it; therefore, as part of the creation process, you must create a security group that provides access and then associate it with your DB instance. Next, this section shows you how to connect to the DB instance using a client application on your local computer. Finally, you delete the DB instance.

Getting Started flow chart

Signing up for Amazon RDS

To use the Amazon Relational Database Service (Amazon RDS), you must first sign up for the service. After you sign up for the service, you can get your user credentials and start using the Amazon RDS service.

Important

The DB instance you're about to launch will be live (and not running in a sandbox). You will incur the standard Amazon RDS usage fees for the instance until you terminate it. The total charges will be minimal if you complete the exercise described here in one sitting and delete your DB instance when you are finished. For more information about Amazon RDS usage rates, go to the Amazon RDS product page.

To use Amazon RDS, you need an AWS account. If you don't already have one, you'll be prompted to create one when you sign up for Amazon RDS.

To sign up for Amazon RDS

  1. Go to http://aws.amazon.com/rds and click Sign Up for Amazon RDS Now.

  2. Follow the on-screen instructions.

Authorize Access: Creating a Security Group

Depending on your AWS account and region, you can create a DB instance on two platforms: EC2-Classic or EC2-VPC. Each platform requires its own security group. The EC2-Classic platform is the original platform used by Amazon RDS and requires a DB security group, and the EC2-VPC platform provides a default VPC (virtual private cloud) where a new DB instance is created, and requires either an EC2 or VPC security group. If you are a new Amazon RDS customer or you are creating DB instances in a region you have not used before, you are likely on the EC2-VPC platform.

When you create an Amazon RDS DB instance on either the EC2-VPC or the EC2-Classic platform, the instance is created with a firewall that does not allow any connections to it. You must create a security group and specify the port, IP addresses, or EC2 instances that can access your DB instance. You then associate that security group with the DB instance when you create the instance. If you do not know the IP address or port you should use when creating the security group and the DB instance, talk with your network administrator to determine the values you should use. For more information about the EC2-VPC and EC2-Classic platforms, and about EC2 security groups, see Amazon EC2 Security Groups. For information on creating a VPC security group, see Security Groups for Your VPC.

Determining Whether You are Using the EC2-VPC or EC2-Classic Platform

You can tell which platform your AWS account in a given region is using by looking at the RDS console home page.

If Supported Platforms indicates VPC, your AWS account in the current region uses the EC2-VPC platform, and uses a default VPC. The name of the default VPC is shown below the supported platform. To provide access to a DB instance created on the EC2-VPC platform, you must create an EC2 or VPC security group.

VPC platform

If Supported Platforms indicates EC2,VPC, your AWS account in the current region uses the EC2-Classic platform, and you do not have a default VPC. To provide access to a DB instance created on the EC2-Classic platform, you must create a DB security group. Note that you can create a VPC on the EC2-Classic platform, but one is not created for you by default as it is on the EC2-VPC platform.

EC2, VPC platform

Creating a Security Group for the EC2-VPC and EC2-Classic Platforms

Now that you know which platform you are creating your DB instance on, you can create a security group that will allow you access to your DB instance.

Creating an EC2/VPC Security Group for a DB Instance in a VPC

If you are creating a DB instance on the EC2-VPC platform and therefore in a default VPC, you must create either an EC2 or VPC security group that will allow access through your firewall to the DB instance that is in a VPC.

VPC platform

To create an EC2 security group for your DB instance, you first create the security group, then you specify a custom TCP rule that specifies the port you will use for your DB instance and a single IP address or a range of IP addresses that you will allow to connect to your DB instance. Since these IP addresses will be allowed access, it is important that you grant access only to the correct IP addresses.

To create an EC2 security group to Use with a DB Instance on the EC2-VPC platform

  1. Sign in to the AWS Management Console and open the Amazon EC2 console.

  2. In the navigation pane, click Security Groups.

  3. Click Create Security Group.

  4. Specify a name and description for the security group. Select the ID of your VPC for VPC, and then click Yes, Create.

  5. Select the check box for the EC2 security group you just created, then select the Inbound tab.

    In the Create a new rule drop down list, select Custom TCP rule. Enter the port value you will use when you create the DB instance in the Port range text box. Enter the IP address you will use to access the DB instance in the Source text box.

  6. Click Add Rule. You can add additional rules by repeating the process of entering a port range and source IP address values.

  7. Click Apply Rule Changes.

    VPC platform

Creating a DB Security Group for a DB Instance on the EC2-Classic platform

If you are creating a DB instance on the EC2-Classic platform, you must create A DB security group that will allow access through your firewall to the DB instance.

Classic platform

To create a DB security group for your DB instance, you first create the DB security group, and then you specify CIDR (Classless Inter-Domain Routing) values for either a single IP address or a range of IP addresses that you will allow to connect to your DB instance. Since these IP addresses will be allowed access, it is important that you grant access only to the correct IP addresses.

To create a DB security group for a DB Instance on the EC2-Classic platform

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

  2. Click Security Groups in the navigation pane on the left side of the window.

  3. Click Create DB Security Group.

    create sec group

  4. Type the name and description of the new DB security group in the Name and Description text boxes. Note that the security group name cannot contain spaces and cannot start with a number.

    create sec group

  5. Click Yes, Create. The DB security group will be created. A newly created DB security group does not provide access to a DB instance by default. You must specify a range of IP addresses or an EC2 security group that can have access to the DB instance.

  6. Click the details page icon for the DB security group you just created.

    view sec group

  7. In the Security Group Details section, select CIDR/IP from the Connection Type drop-down list, type the CIDR range for the ingress rule you would like to add to this DB security group into the CIDR text box, and click Add.

    Tip

    The AWS Management Console displays a CIDR IP based on your connection below the CIDR text field. If you are not accessing the DB instance from behind a firewall, this could be the CIDR IP you would use.

    add sec group

The status of the ingress rule will be authorizing until the new ingress rule has been applied to all DB instances that are associated with the DB security group that you modified. After the ingress rule has been successfully applied, the status will change to authorized. You can then use the DB security group when you create a DB instance in the next section.

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

You can create, or launch, a DB instance using any of the DB engine versions available in the region you've selected. Editions of MySQL, Oracle, PostgreSQL, and Microsoft SQL Server are available in all regions. Creating a DB instance and connecting to a database on a DB instance is slightly different for each of the DB engines; select the DB engine below that you want to create for detailed information on creating the DB instance.

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 Amazon RDS 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.

Creating a MySQL DB Instance

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

In this example, you create a DB instance running the MySQL database engine called west2-mysql-instance1, with a db.m1.small DB instance class, 5 GB 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, select the region in which you want to create the DB instance.

  3. In the navigation pane, click Instances.

  4. Click Launch DB Instance. The Launch DB Instance Wizard opens on the Engine Selection page.

    Engine selection

  5. On the Engine Selection page, click Select for the MySQL DB engine.

  6. On the DB Instance 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, click Continue.

    For this parameter... ...Do this:

    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.m1.small to select a configuration that equates to 1.7 GB memory, 1 ECU (1 virtual core with 1 ECU), 64-bit platform, and moderate I/O capacity.

    Multi-AZ Deployment

    Select No to create your DB instance in a single availability zone.

    Auto Minor Version Upgrade

    Select Yes to enable your DB instance to receive minor DB engine version upgrades automatically when they become available.

    Allocated Storage

    Type 5 to allocate 5 GB of storage for your database.

    Use Provisioned IOPS

    Leave the check box unselected. This option turns on Provisioned IOPS (I/O operations per second), a high-performance storage option in Amazon RDS that is optimized for I/O-intensive, transactional (OLTP) database workloads.

    DB Instance Identifier

    Type a name for the DB instance that is unique for your account in the region you selected. You may chose to add some intelligence to the name such as including the region and DB engine you selected, for example west2-mysql-instance1.

    Master User Name

    Type a name using alphanumeric characters that you will use as the master user name to log on to your DB instance. This will be the user name you use to logon to your database on the DB instance for the first time.

    Master User Password

    Type a password that contains from 8 to 16 printable ASCII characters (excluding /,", and @) for your master user password. This will be the password you will use when you use the user name to logon to your database.

    DB instance details

  7. On the Additional Configuration 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 click Continue.

    For this parameter... ...Do this:

    Database Name

    Type a name for your database of up to 8 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 unless you have a specific port you want to access the database through. MySQL installations default to port 3306.

    Choose a VPC

    This setting depends on the platform you are on. If you are creating a DB instance on the EC2-VPC platform, select the default VPC. If you are creating a DB instance on the E2-Classic platform, select Not in VPC. For more information about VPC, see Amazon RDS and the Amazon Virtual Private Cloud Service.

    Publicly Accessible

    (Only applies if you choose a VPC) Select Yes to give the DB instance a public IP address; otherwise, select No. For more information about hiding DB instances from public access, see Hiding a DB instance in a VPC from the Internet.

    Availability Zone

    Leave the default of No Preference unless you want to specify a particular Availability Zone.

    Option Group

    Select the default value of default:mysql-5-5 since this option group is used with the MySQL version you selected on the previous page.

    Parameter Group

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

    DB Security Groups

    Select the DB security group that you created in a previous step in the Getting Started section.

    Additional Configuration panel

  8. On the Management Options page, you can specify backup and maintenance options for your DB instance. Accept the default values, and then click Continue.

    Management Options panel
  9. On the Review page, review the options for your DB instance. If you need to make any changes, click Back to return to the appropriate page, and then make the necessary corrections. When all the settings are as you want them, click Launch DB Instance.

  10. On the final page of the wizard, click Close.

  11. On the RDS console, the new DB instance appears in the list of DB instances. 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. Depending on the DB instance class and store allocated, it could take several minutes for the new DB instance to become 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.

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

  • Type the following command at a command prompt on a client computer to connect to a database on a MySQL DB instance using the MySQL monitor. Substitute the DNS name for your DB instance for <endpoint>, the master user name you used for <mymasteruser>, and the master password you used for <password>.

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

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

Creating an Oracle DB Instance and Connecting to a Database on an Oracle DB Instance

The easiest way to create an Oracle DB instance is to use the RDS console. Once you have created the DB instance, you can use standard Oracle client utilities such as SQL Developer to connect to the instance.

In this example, you create a DB instance running the Oracle database engine called west2-oracle1, with a db.m1.small DB instance class, 10 GB of storage, and automated backups enabled with a retention period of one day.

Creating a DB Instance Running the Oracle DB Engine

To launch an Oracle 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, select the region in which you want to create the DB instance.

  3. In the navigation pane, click DB Instances.

  4. Click Launch DB Instance to start the Launch DB Instance Wizard.

    The wizard opens on the Engine Selection page.

    Engine selection

  5. In the Launch DB Instance Wizard window, click the Select button for the Oracle DB engine.

  6. On the DB Instance Details page, specify your DB instance information. The following table shows settings for an example DB instance. Click Continue when you are finished.

    For this parameter... ...Do this:

    License Model

    Select Bring Your Own License, to provide your own license for using Oracle. Some regions support additional licensing options for Oracle.

    DB Engine Version

    Select the default version of Oracle.

    DB Instance Class

    Select db.m1.small to select a configuration that equates to 1.7 GB memory, 1 ECU (1 virtual core with 1 ECU), 64-bit platform, and moderate I/O capacity.

    Multi-AZ Deployment

    Select No to create your DB instance in a single availability zone.

    Auto Minor Version Upgrade

    Select Yes to enable your DB instance to receive minor DB Engine version upgrades automatically when they become available.

    Allocated Storage

    Type 10 to allocate 10 GB 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.

    Use Provisioned IOPS

    Leave the check box unselected. This option turns on Provisioned IOPS (I/O operations per second), a high-performance storage option in RDS that is optimized for I/O-intensive, transactional (OLTP) database workloads.

    DB Instance Identifier

    Type a name for the DB Instance that is unique for your account in the region you selected. You may choose to add some intelligence to the name such as including the region and DB engine you selected, for example oracle-unstance1.

    Master User Name

    Type a name that you will use as the master user name to log on to your DB instance with all database privileges. This user account is used to log into the DB instance and is granted the "DBA" role.

    Master User Password

    Type a password that contains from 8 to 30 printable ASCII characters (excluding /,", and @) for your master user password.

    DB instance details

  7. On the Additional Configuration page, provide additional information that RDS needs to launch the Oracle DB instance. The table shows settings for an example DB instance. Specify your DB instance information, then click Continue.

    For this parameter... ...Do this:

    Database Name

    Type a name for your database that begins with a letter and contains up to 8 alpha-numeric characters. If you do not provide a name, Amazon RDS will not create a database on the DB instance you are creating.

    Database Port

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

    Choose a VPC

    This setting depends on the platform you are on. If you are creating a DB instance on the EC2-VPC platform, select the default VPC. If you are creating a DB instance on the E2-Classic platform, select Not in VPC. For more information about VPC, see Amazon RDS and the Amazon Virtual Private Cloud Service.

    Publicly Accessible

    (Only applies if you choose a VPC) Select Yes to give the DB instance a public IP address; otherwise, select No. For more information about hiding DB instances from public access, see Hiding a DB instance in a VPC from the Internet.

    Availability Zone

    Leave the default of No Preference.

    Character Set Name

    Select the default value of AL32UTF8 for the Unicode 5.0 UTF-8 Universal character set. Note that you cannot change the character set after the DB instance is created.

    Option Group

    Select the default value of default:oracle-ee-11-2.

    DB Parameter Group

    Leave the default value of default.oracle-ee-11.2.

    DB Security Groups

    Select the DB security group you created in the previous section.

    Additional Configuration panel

  8. On the Management Options page, you can specify backup and maintenance options for your DB instance. For this example, accept the default values, and then click Continue.

    Management Options panel

    When all the settings are as you want them, click Continue.

  9. On the Review page, review the options for your DB instance. If you need to make any changes, click Back to return to the appropriate page, and then make the necessary corrections. When all the settings are as you want them, click Launch DB Instance.

  10. On the final page of the wizard, click Close.

  11. On the RDS console, the new DB instance appears in the list of DB instances. 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 the DB instance. Depending on the DB instance class and store allocated, it could take several minutes for the new instance to be available.

    My DB instances list

Connecting to a DB Instance Running the Oracle Database Engine

Once Amazon RDS provisions your DB instance, you can use any standard SQL client application to connect to the instance. In this example, you connect to a DB instance running the Oracle database engine using the Oracle command line tools. For more information on using Oracle, go to the Oracle website.

This example uses the Oracle sqlplus command line utility. This utility is part of the Oracle software distribution. To download a stand-alone version of this utility, go to the SQL*Plus User's Guide and Reference.

  1. Open the RDS console, then select Instances in the left column to display a list of your DB instances.

  2. In the row for your Oracle DB instance, select the arrow to display the summary information for the instance.

  3. The Endpoint field contains part of the connection information for your DB instance. The Endpoint field has two parts separated by a colon (:). The part before the colon is the DNS name for the instance, the part following the colon is the port.

    My DB instances list
  4. Type the following command on one line at a command prompt to connect to a DB instance using the sqlplus utility. The value for Host will be the DNS name for your DB instance, the value for Port will be the port you assigned the DB instance, and the value for the Oracle SID will be the name of the DB instance's database that you specified when you created the DB instance, not the name of the DB instance.

    PROMPT>sqlplus 'mydbusr@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<endpoint>)
        (PORT=<port number>))(CONNECT_DATA=(SID=<database name>)))'

    You will see output similar to the following.

    SQL*Plus: Release 11.1.0.7.0 - Production on Wed May 25 15:13:59 2011
    
    SQL>
    

Creating and Connecting to a SQL Server DB Instance

The easiest way to create a DB instance is to use the RDS console. Once you have created the DB instance, you can use standard SQL Server utilities to connect to the DB instance such as the Microsoft SQL Server Management Studio utility.

Creating a SQL Server DB Instance

To create a DB Instance Running the Microsoft SQL Server DB Engine

  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, select the region in which you want to create the DB instance.

  3. In the navigation pane, click Instances.

  4. Click Launch DB Instance to start the Launch DB Instance Wizard.

    The wizard opens on the Engine Selection page.

    Engine selection

  5. In the Launch DB Instance Wizard window, click the Select button for the SQL Server DB engine you want to use.

  6. On the DB Instance Details page, specify your DB instance information. The following table shows settings for an example DB instance using SQL Server Standard Edition. Click Continue when you are finished.

    For this parameter... ...Do this:

    License Model

    Select, License Included, to use the general license agreement for Microsoft SQL Server.

    DB Engine Version

    Select the default version of SQL Server.

    DB Instance Class

    Select db.m1.small to select a configuration that equates to 1.7 GB memory, 1 ECU (1 virtual core with 1 ECU), 64-bit platform, and moderate I/O capacity. For more information about all the DB instance class options, see DB Instance Class.

    Multi-AZ Deployment

    This feature is only available for Oracle and MySQL DB instances.

    Auto Minor Version Upgrade

    Select Yes to enable your DB instance to receive minor DB engine version upgrades automatically when they become available.

    Allocated Storage

    Type 200 to allocate 200 GB 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 Relational Database Service Features.

    Use Provisioned IOPS

    Leave the check box unselected. This option turns on Provisioned IOPS (I/O operations per second), a high-performance storage option in RDS that is optimized for I/O-intensive, transactional (OLTP) database workloads. For more information about high performance storage, see Working with Provisioned IOPS Storage.

    DB Instance Identifier

    Type a name for the DB instance of 15 alphanumeric characters or less that is unique for your account in the region you selected. You may chose to add some intelligence to the name such as including the region and DB Engine you selected, such as sqlsv-instance1.

    Master User Name

    Type a name that you will use as the master username to log on to your DB Instance with all database privileges. The master username is a SQL Server Authentication login that is a member of the processadmin, public, and setupadmin fixed server roles.

    Master User Password

    Type a password that contains from 8 to 128 printable ASCII characters (excluding /,", and @) for your master user password.

    DB instance details

  7. On the Additional Configuration page, provide additional information that RDS needs to launch the SQL Server DB instance. The table shows settings for an example DB instance. Specify your DB instance information, then click Continue.

    For this parameter... ...Do this:

    Database Port

    Leave the default value of 1433 unless you have a specific port you want to access the database through. SQL Server installations default to port 1433.

    Availability Zone

    Leave the default of No Preference unless you want to specify a particular Availability Zone.

    Choose a VPC

    This setting depends on the platform you are on. If you are creating a DB instance on the EC2-VPC platform, select the default VPC. If you are creating a DB instance on the E2-Classic platform, select Not in VPC. For more information about VPC, see Amazon RDS and the Amazon Virtual Private Cloud Service.

    Publicly Accessible

    (Only applies if you choose a VPC) Select Yes to give the DB instance a public IP address; otherwise, select No. For more information about hiding DB instances from public access, see Hiding a DB instance in a VPC from the Internet.

    Parameter Group

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

    DB Security Groups

    Select the security group you want to use. For more information about security groups, see Working with DB Security Groups.

    Additional Configuration panel

  8. On the Management Options page, you can specify backup and maintenance options for your DB instance. For this example, accept the default values, and then click Continue. Note that setting the Backup Retention Period to zero disables automatic backups. For more information about the maintenance window, see Adjusting the Preferred Maintenance Window. For more information on backups and the backup retention period, see DB Instance Backups.

    When all the settings are as you want them, click Continue.

    Management Options panel
  9. On the Review page, review the options for your DB instance. If you need to make any changes, click Back to return to the appropriate page, and then make the necessary corrections. When all the settings are as you want them, click Launch DB Instance.

  10. On the final page of the wizard, click Close.

  11. On the RDS console, the new DB instance appears in the list of DB instances. 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 the DB instance. Depending on the DB instance class and store allocated, it could take several minutes for the new instance to be available.

    My DB instances list

Connecting to a SQL Server DB Instance Using Microsoft SQL Server Management Studio

This example uses the Microsoft SQL Server Management Studio utility. This utility is part of the Microsoft SQL Server software distribution. To download a stand-alone version of this utility, go to the Microsoft Download Center - Microsoft SQL Server Management Studio Express.

To connect to a DB Instance using Microsoft SQL Server Management Studio

  1. Find the DNS name and port for your DB Instance.

    1. Open the RDS console, then select Instances in the left column to display a list of your DB instances.

    2. In the row for your Oracle DB instance, select the arrow to display the summary information for the instance.

    3. The Endpoint field has two parts separated by a colon (:). The part before the colon is the DNS name for the instance, the part following the colon is the port.

      Locate DB Instance endpoint and port
  2. Run Microsoft SQL Server Management Studio.

  3. The Connect to Server dialog box appears.

    Connect to Server dialog
  4. In the Server type: drop-down list box, select Database Engine.

  5. In the Server name: text field, enter or paste the DNS name of the DB Instance running the Microsoft SQL Server database engine, followed by a comma and then the port number of the DB Instance. For example, the Server name could be: sqlsv-instance1.cg034hpkmmjt.us-east-1.rds.amazonaws.com,1433.

  6. From the Authentication drop-down list box, select SQL Server Authentication.

  7. Enter the master user name for the DB Instance in the Login: text box.

  8. Enter the password for the master user in the Password: text box.

  9. Click the Connect button.

    After a few moments, Microsoft SQL Server Management Studio should be connected to your DB Instance.

  10. Click the New Query button at the top left of the SQL Server Management Studio window.

    A new SQL Query window will open.

    SQL Query Window
  11. Type the following SQL query:

    select @@VERSION
  12. Click the ! Execute button on the SQL Enterprise Manager toolbar to run the query.

    You should see a version string returned from your Microsoft SQL Server DB Instance displayed in the output window.

    SQL Query results

Troubleshooting a Connection to a DB Instance Running SQL Server

There are two common causes for problems if you are having problems connecting to a SQL Server DB instance: the access rules enforced by your firewall and the IP addresses you authorized to access the DB instance in the DB security group (or VPC security group if your DB instance is inside a VPC). If you used Microsoft SQL Server Management Studio and you followed the settings specified in the steps above and you are unable to connect, the problem is most likely the egress or ingress rules on your firewall. If you cannot send out or receive communications over the port you specified when you created the DB instance, you will not be able to connect to the DB instance. Check with your network administrator to determine if the port you specified for your DB instance is allowed to be used for inbound and outbound communication.

Here are a few things to check if you know that you can send and receive communications through your firewall for the port you specified when you created the DB instance.

  • Could not open a connection to SQL Server - Microsoft SQL Server, Error: 53 - You must include the port number when you specify the Server Name when using Microsoft SQL Server Management Studio. For example, the server name for a DB instance (including the port number) could be: sqlsvr-pdz.c6c8mdfntzgv0.us-west-2.rds.amazonaws.com,1433.

  • No connection could be made because the target machine actively refused it - Microsoft SQL Server, Error: 10061 - You were able to reach the DB instance but the connection was refused. This is often caused by the user name or password being incorrect.

Creating and Connecting to a PostgreSQL DB Instance

The easiest way to create a DB instance is to use the RDS console. Once you have created the DB instance, you can use standard SQL client utilities to connect to the DB instance such as the pgAdmin utility. In this example, you create a DB instance running the PostgreSQL database engine called west2-postgres1, with a db.m1.small DB instance class, 10 GB of storage, and automated backups enabled with a retention period of one day.

Creating a PostgreSQL DB Instance

To create a DB Instance Running the PostgreSQL DB Engine

  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, select the region in which you want to create the DB instance.

  3. In the navigation pane, click DB Instances.

  4. Click Launch DB Instance to start the Launch DB Instance Wizard.

    The wizard opens on the Engine Selection page.

    Engine selection

  5. On the Engine Selection page, click the Select button for the PostgreSQL DB engine.

  6. Next, the Production? page asks if you are planning to use the DB instance you are creating for production. If you are, select Yes. By selecting Yes, the failover option Multi-AZ and the Provisioned IOPS storage option will be preselected in the following step. Click Next Step when you are finished.

  7. On the DB Instance Details page, specify your DB instance information. Click Next Step when you are finished.

    For this parameter... ...Do this:

    License Model

    PostgreSQL has only one license model. Select the default, Postgresql License, to use the general license agreement for PostgreSQL.

    DB Engine Version

    Select the default version of PostgreSQL.

    DB Instance Class

    Select db.m1.small to select a configuration that equates to 1.7 GB memory, 1 ECU (1 virtual core with 1 ECU), 64-bit platform, and moderate I/O capacity. For more information about all the DB instance class options, see DB Instance Class.

    Multi-AZ Deployment

    Select No to create your DB instance in a single availability zone . For more information about multiple Availability Zones, see Regions and Availability Zones.

    Auto Minor Version Upgrade

    Select Yes to enable your DB instance to receive minor DB engine version upgrades automatically when they become available.

    Allocated Storage

    Type 10 to allocate 10 GB 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 Relational Database Service Features.

    Use Provisioned IOPS

    Leave the check box unselected. This option turns on Provisioned IOPS (I/O operations per second), a high-performance storage option in Amazon RDS that is optimized for I/O-intensive, transactional (OLTP) database workloads. For more information about high performance storage, see Working with Provisioned IOPS Storage.

    DB Instance Identifier

    Type a name for the DB instance that is unique for your account in the region you selected. You may chose to add some intelligence to the name such as including the region and DB engine you selected, for example west2-postgres1.

    Master Username

    Type a name using alphanumeric characters that you will use as the master user name to log on to your DB instance. For information on the default privileges granted to the master user name, see Things You Should Know About PostgreSQL on Amazon RDS

    Master Password

    Type a password that contains from 8 to 128 printable ASCII characters (excluding /,", and @) for your master user password.

    DB instance details

  8. On the Additional Config page, provide additional information that RDS needs to launch the PostgreSQL DB instance. The table shows settings for an example DB instance. Specify your DB instance information, then click Next Step.

    For this parameter... ...Do this:

    Database Name

    Type a name for your database of up to 63 alpha-numeric characters. If you do not provide a name, no default database on the DB instance is created.

    Database Port

    Specify a port you want to use to access the database. PostgreSQL installations default to port 5432 .

    Choose a VPC

    This setting depends on the platform you are on. If you are creating a DB instance on the EC2-VPC platform, select the default VPC. If you are creating a DB instance on the E2-Classic platform, select Not in VPC. For more information about VPC, see Amazon RDS and the Amazon Virtual Private Cloud Service.

    Availability Zone

    Leave the default of No Preference. For more information about Availability Zones, see Regions and Availability Zones.

    Option Group

    Option groups are currently not used with PostgreSQL DB instances. For more information about option groups, see Working with Option Groups.

    Parameter Group

    Select the default parameter group. Each PostgreSQL version has a default parameter group you can use, or you can create your own parameter group. For more information about parameter groups, see Working with DB Parameter Groups.

    Security Groups

    Select the security group you created in the previous section. The security group you select must specify the IP addresses or EC2 instances that can access the DB instance. For more information about security groups, see Working with DB Security Groups.

    Additional Configuration panel

  9. On the Management Options page, you can specify backup and maintenance options for your DB instance. Click Next Step when the settings are as you want them. For more information about the maintenance window, see Adjusting the Preferred Maintenance Window. For more information on backups and the backup retention period, see DB Instance Backups.

    Management Options panel
  10. On the Review page, review the options for your DB instance. If you need to make any changes, click Previous to return to the appropriate page, and then make the necessary corrections. When all the settings are as you want them, click Launch DB Instance.

  11. On the final page of the wizard, click Close.

  12. On the Amazon RDS console, the new DB instance appears in the list of DB instances. 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 the DB instance. Depending on the DB instance class and store allocated, it could take several minutes for the new instance to be available.

    My DB instances list

Connecting to a PostgreSQL DB Instance

After Amazon RDS provisions your DB instance, you can use any standard SQL client application to connect to the instance. It is important to note that the security group you assigned to the DB instance when you created it must allow access to the DB instance. If you have difficulty connecting to the DB instance, the problem is most often with the access rules you set up in the security group you assigned to the DB instance.

This section shows two ways to connect to a PostgreSQL DB instance. The first example uses pgAdmin, a popular Open Source administration and development tool for PostgreSQL. You can download and use pgAdmin without having a local instance of PostgreSQL on your client computer. The second example uses psql, a command line utility that is part of a PostgreSQL installation. To use psql, you must have a PostgreSQL installed on your client computer or have installed the psql client on your machine.

In this example, you connect to a PostgreSQL DB instance using pgAdmin.

Using pgAdmin to Connect to a PostgreSQL DB Instance

To connect to a PostgreSQL DB instance using pgAdmin

  1. Launch the pgAdmin application on your client computer. You can install pgAdmin from http://www.pgadmin.org/.

  2. Select Add Server from the File menu.

  3. In the New Server Registration dialog box, enter the DB instance endpoint (for example, mypostgresql.c6c8dntfzzhgv0.us-west-2.rds.amazonaws.com) in the Host text box. Do not include the colon or port number as shown on the Amazon RDS console (mypostgresql.c6c8dntfzzhgv0.us-west-2.rds.amazonaws.com:5432).

    Enter the port you assigned to the DB instance into the Port text box. Enter the user name and user password you entered when you created the DB instance into the Username and Password text boxes, respectively.

    Postgres connect

  4. Click OK.

  5. In the Object browser, expand the Server Groups. Select the Server (the DB instance) you created, and then select the database name.

    Postgres connect

  6. Click the plugin icon and click PSQL Console. The psql command window opens for the default database you created.

    Postgres connect

  7. Use the command window to enter SQL or psql commands. Type \q to close the window.

Using psql to Connect to a PostgreSQL DB Instance

If your client computer has PostgreSQL installed, you can use a local instance of psql to connect to a PostgreSQL DB instance. To connect to your PostgreSQL DB instance using psql, you need to provide host information and access credentials.

The following format is used to connect to a PostgreSQL DB instance on Amazon RDS:

            
psql --host=<DB instance endpoint> --port=<port> --username=<master user name> --password --dbname=<database name>
        
        

For example, the following command connects to a database called mypgdb on a PostgreSQL DB instance called mypostgresql using fictitious credentials:

psql --host=mypostgresql.c6c8mwvfdgv0.us-west-2.rds.amazonaws.com --port=5432 --username=awsuser --password --dbname=mypgdb
        
Troubleshooting Connection Issues

By far the most common problem that occurs when attempting to connect to a database on a DB instance is the access rules in the security group assigned to the DB instance. If you used the default DB security group when you created the DB instance, chances are good that the security group did not have the rules that will allow you to access the instance. For more information about Amazon RDS security groups, see Amazon RDS Security Groups

The most common error is could not connect to server: Connection timed out. If you receive this error, check that the host name is the DB instance endpoint and that the port number is correct. Check that the security group assigned to the DB instance has the necessary rules to allow access through any firewall your connection may be going through.

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 DB Instances list, select the check box next to the DB instance you wish to delete.

  3. Click Instance Actions, and then select Delete from the dropdown menu.

  4. Select No in the Create final Snapshot? drop-down list box.

  5. Click Yes, Delete.