Blog

Create aws rds database

Cover Image for Create aws rds database
Aswin Pyakurel

Step-by-Step Guide for Creating an AWS RDS Database, connecting to it with a MySQL client, and Creating a Table with a few Columns and Inserting some Data into it

Step 1: Create a VPC (Virtual Private Cloud) Log in to your AWS account, and navigate to the VPC console. Click on "Create VPC" and follow the instructions. You'll need to select a CIDR block and create at least one subnet.

Step 2: Create a security group for the database Navigate to the EC2 console, and click on "Security Groups" in the sidebar. Click on "Create Security Group," and fill out the form as follows:

  • Security group name: something memorable, like "database-access"
  • Description: a brief description of the security group's purpose
  • VPC: select the VPC you just created
  • Inbound rules: click the "Add Rule" button and choose "MySQL/Aurora" from the dropdown. Keep the default "Anywhere" value for the source.

Step 3: Create an RDS instance Navigate to the RDS console, and click on "Create Database." Choose "MySQL" as the engine, and select the appropriate version. Configure the database options as needed, including the username and password. Make sure to choose the appropriate VPC and subnet(s). For the "Security group" option, select the security group you just created.

Step 4: Connect to the RDS instance You can connect to the RDS instance using any MySQL client that supports SSL. In this example, we'll use the mysql command line client. To connect, you'll need the endpoint (hostname or IP address) of the RDS instance, as well as the username and password you created earlier.

mysql -h your-rds-instance-endpoint -u your-username -p

Step 5: Create a table Onceyou're connected to the RDS instance, you can create a table using standard SQL syntax. For example, to create a simple table called "employees" with three columns (id, name, and salary), you could use the following command:

CREATE TABLE employees (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
salary DECIMAL(10,2),
PRIMARY KEY (id)
);

Step 6: Insert some data After creating the table, you can insert some data using the INSERT statement. For example:

INSERT INTO employees (name, salary) VALUES ('Jane Smith', 60000.00);
INSERT INTO employees (name, salary) VALUES ('John Doe', 50000.00);

That's it! You now have an AWS RDS instance with a MySQL database, a table, and some data. You can continue to manage the database and its contents using SQL commands from any MySQL client that supports SSL connections.


More Stories

Cover Image for Is NFT useful?

Is NFT useful?

Aswin Pyakurel
Cover Image for Create solana dapp

Create solana dapp