How Do You Connect to an Aurora MySQL Database from a Linux Server with a MySQL Command?

Problem scenario
You are using an Aurora or RDS MySQL database. You have a Linux server that you want to run MySQL commands from (rather than install a SQL front-end). What should you do?

Solution

1. Install a MySQL client. If you need assistance with this, see this posting.

2. Make sure the Security Group governing the Aurora or RDS region allows for incoming connections from one of the following:
a) if you are using an EC-2 server in the same region, the internal IP address of the server ip addr show | grep inet
b) the external IP address of the server (e.g., visible in the result of a curl icanhazip.com command)

3. Test it by using this (with no special designation of a database beyond the endpoint and no port number):

mysql -hnameofauroraendpoing-us-west-2b.abcd1234.us-west-2.rds.amazonaws.com -ujdoe -pgoodpassword

# (Replace "nameofauroraendpoing-us-west-2b.abcd1234.us-west-2.rds.amazonaws.com" with the endpoint.
#  You can find it in the AWS web console or via an AWS CLI command.
#  If you have the AWS CLI configured run this commmand: aws rds describe-db-instances | grep Address
#  If you need assistance installing and configuring the AWS CLI, see the postings linked at the bottom.* 
#  Replace "jdoe" with the Aurora database master username.
#  Replace "goodpassword" with the Aurora database master password.

*One posting is How Do You Install and Configure the AWS CLI on a Linux Server (without the pip Command)?"
Another article is How Do You Install the AWS CLI on an Ubuntu Server?

Leave a comment

Your email address will not be published. Required fields are marked *