Skip to content
Eren Gaygusuz
Go back

Using a MySQL Database Server on AWS RDS

Amazon RDS lets you run a managed relational database without maintaining the database server yourself. In this guide, I create a MySQL database instance on AWS RDS, connect to it with MySQL Workbench, create a small Library schema, and adjust a custom parameter group when MySQL function creation requires an extra setting.

The main flow is: create the RDS instance, allow the connection through the security group, connect with MySQL Workbench, test the database with tables and queries, then update the RDS parameter group for server-level MySQL behavior.

AWS RDS MySQL connection flow with MySQL Workbench and parameter settings

Table of contents

Open Table of contents

Creating a MySQL Database in AWS RDS

Start from the AWS Console and open the RDS service. Create a new database and choose MySQL as the engine. For a learning setup, the Free Tier option is usually enough, but in a real project you should choose the instance class, storage, backup, and availability options based on the workload.

Opening the RDS service from the AWS Console

Here, we start database creation in Amazon RDS.

Starting database creation in Amazon RDS

Here, we choose MySQL as the RDS database engine.

Choosing MySQL as the RDS database engine

Here, we select the RDS MySQL database template.

Selecting the RDS MySQL database template

Configure the database identifier and master credentials carefully. The endpoint will be generated by AWS, but the user name and password are needed later in MySQL Workbench.

Setting the RDS database identifier and credentials

Here, we choose the RDS instance configuration.

Choosing the RDS instance configuration

This screen shows Configuring RDS storage options.

Configuring RDS storage options

For local connection from your computer, networking settings matter. The database needs to be reachable from your machine, and the related security group must allow inbound MySQL traffic on port 3306.

Configuring RDS connectivity and network settings

Here, we choose VPC and security group settings for RDS.

Choosing VPC and security group settings for RDS

This screen shows Configuring database authentication options.

Configuring database authentication options

Review the remaining settings and create the database. RDS needs a few minutes to provision the instance before the endpoint becomes available.

Reviewing RDS database creation options

Here, we create the RDS MySQL database instance.

Creating the RDS MySQL database instance

This screen shows RDS MySQL database creation in progress.

RDS MySQL database creation in progress

This screen shows RDS MySQL database instance created.

RDS MySQL database instance created

Connecting with MySQL Workbench

After the database is available, open its details page and copy the endpoint. In MySQL Workbench, create a new connection with that endpoint, port 3306, and the master user credentials you entered during RDS setup.

Opening the RDS database details page

Here, we copy the RDS database endpoint.

Copying the RDS database endpoint

Here, we create a new MySQL Workbench connection.

Creating a new MySQL Workbench connection

Here, we enter RDS endpoint and credentials in MySQL Workbench.

Entering RDS endpoint and credentials in MySQL Workbench

If the first connection attempt fails, the usual reason is the security group. Open the security group attached to the RDS instance and add an inbound rule for MySQL/Aurora on port 3306. For personal testing you may use your own IP address; for production, keep this rule as narrow as possible.

MySQL Workbench connection test for RDS

Here, we open the RDS security group.

Opening the RDS security group

Here, we edit inbound rules for the RDS security group.

Editing inbound rules for the RDS security group

Here, we add a MySQL inbound rule for port 3306.

Adding a MySQL inbound rule for port 3306

With the rule in place, connect again from MySQL Workbench and verify that the server opens successfully.

Successful MySQL Workbench connection to AWS RDS

Creating a Sample Library Database

To test the new server, create a simple Library schema in MySQL Workbench. This gives you a practical way to verify schema creation, tables, relationships, inserts, and select queries.

Creating a new Library schema in MySQL Workbench

Here, we apply schema creation in MySQL Workbench.

Applying schema creation in MySQL Workbench

Create the base tables such as authors and books, then add the relationship table that connects them. This is a small many-to-many example: one author can have multiple books, and a book can be related to multiple authors if needed.

Creating the first table in the Library schema

This screen shows Defining table columns in MySQL Workbench.

Defining table columns in MySQL Workbench

Here, we apply table creation in MySQL Workbench.

Applying table creation in MySQL Workbench

Here, we create another Library table.

Creating another Library table

This screen shows Configuring table columns and keys.

Configuring table columns and keys

Here, we create a relationship table for books and authors.

Creating a relationship table for books and authors

After the tables are ready, insert sample rows and run a join query to make sure the relationships return the expected results.

Inserting sample author records

This screen shows Inserting sample book records.

Inserting sample book records

This screen shows Inserting relationship records for books and authors.

Inserting relationship records for books and authors

Here, we run a select query in MySQL Workbench.

Running a select query in MySQL Workbench

Here, we run a join query for the Library database.

Running a join query for the Library database

Here, we view Library query results in MySQL Workbench.

Viewing Library query results in MySQL Workbench

Creating Views, Procedures, and Functions

Once the base query works, you can turn repeated SQL logic into reusable database objects. Start with a view for the join query, then create a stored procedure for reusable execution.

Creating a view in MySQL Workbench

This screen shows Writing view SQL for the Library database.

Writing view SQL for the Library database

Here, we apply view creation in MySQL Workbench.

Applying view creation in MySQL Workbench

This screen shows Querying the created view.

Querying the created view

Here, we create a stored procedure in MySQL Workbench.

Creating a stored procedure in MySQL Workbench

This screen shows Writing stored procedure SQL.

Writing stored procedure SQL

Here, we apply stored procedure creation.

Applying stored procedure creation

This screen shows Calling the stored procedure.

Calling the stored procedure

Functions are similar, but RDS can block function creation depending on binary logging and trust settings. If you see a privilege-related error while creating a function, the fix is usually to set log_bin_trust_function_creators to 1 in a custom DB parameter group.

Creating a MySQL function in Workbench

This screen shows Writing MySQL function SQL.

Writing MySQL function SQL

This screen shows Function creation error in MySQL Workbench.

Function creation error in MySQL Workbench

Here, we review the MySQL function privilege error.

Reviewing the MySQL function privilege error

Here, we check MySQL function creation behavior.

Checking MySQL function creation behavior

Here, we prepare to update RDS parameter settings.

Preparing to update RDS parameter settings

This screen shows Function execution after configuration review.

Function execution after configuration review

This screen shows MySQL Workbench function test result.

MySQL Workbench function test result

Updating the RDS Parameter Group

RDS default parameter groups cannot be edited directly for many settings, so create a custom parameter group for your MySQL version. Then search for log_bin_trust_function_creators and set it to 1.

Opening parameter groups in Amazon RDS

Here, we create a new RDS parameter group.

Creating a new RDS parameter group

Here, we choose MySQL family for the parameter group.

Choosing MySQL family for the parameter group

This screen shows Naming the custom RDS parameter group.

Naming the custom RDS parameter group

Here, we open parameters inside the custom group.

Opening parameters inside the custom group

Here, we search for log_bin_trust_function_creators.

Searching for log_bin_trust_function_creators

Here, we edit log_bin_trust_function_creators parameter value.

Editing log_bin_trust_function_creators parameter value

After the parameter is updated, attach the custom parameter group to the RDS database instance from the Modify screen. Apply the change and reboot the instance if AWS requires it for the setting to take effect.

Opening the RDS database modify screen

Here, we select the custom parameter group for the RDS database.

Selecting the custom parameter group for the RDS database

This screen shows Continuing RDS database modification.

Continuing RDS database modification

Here, we apply the RDS parameter group change.

Applying the RDS parameter group change

This screen shows RDS database pending parameter group change.

RDS database pending parameter group change

This screen shows Rebooting the RDS database instance.

Rebooting the RDS database instance

Here, we confirm RDS reboot.

Confirming RDS reboot

When the instance is available again, reconnect from MySQL Workbench and create the function one more time. With the parameter enabled, the function can be created and called successfully.

RDS database available after reboot

This screen shows Reconnecting to the RDS database in MySQL Workbench.

Reconnecting to the RDS database in MySQL Workbench

Here, we create the MySQL function after parameter group update.

Creating the MySQL function after parameter group update

This screen shows Calling the MySQL function successfully.

Calling the MySQL function successfully

This screen shows Successful MySQL function result in Workbench.

Successful MySQL function result in Workbench

Summary

With this setup, AWS RDS manages the MySQL server while MySQL Workbench remains the main tool for development and testing. The important parts are allowing the network connection correctly, keeping the database credentials available, and using a custom parameter group when a server-level MySQL setting must be changed.


Share this post:

Comments


Previous Post
Creating an SSL Certificate with AWS ACM and Using It with a Load Balancer
Next Post
Connecting to an AWS EC2 Instance with WinSCP and PuTTY