🔥 Introducing Echo Rewards Pro: Launching with a Huge Early Bird Sale


4 Easy Steps to Connect AWS Lightsail MySQL Remotely

4 Easy Steps to Connect AWS Lightsail MySQL Remotely

You may have an AWS Lightsail instance with a MySQL database server, and you may have been trying to connect AWS Lightsail MySQL remotely from another web application or web server. We will show you the easiest and 100% working method that will guide you to connect AWS Lightsail MySQL remotely with four easy steps.

Don’t worry, you don’t have to be the master of Linux to connect AWS Lightsail MySQL remotely, but we recommend skipping this tutorial if you don’t have a basic knowledge of Linux/Unix Shell Command. Because AWS provides an instance’s root access, making a single mistake can ruin your whole day. But for education purposes, to learn how to connect AWS Lightsail MySQL remotely, you can go ahead.

So let’s get started if you’re confident. 

Table of Content

Connecting AWS Lightsail MySQL Remotely
Connect AWS Lightsail MySQL Remotely

Steps on How to Connect AWS Lightsail MySQL Remotely

Step 1: Find MySQL Configuration 

All you need, connect your Amazon Web Service Lightsail Instance using SSH or connect directly from AWS Lightsail instance panel. Follow the instructions.  

First, install MySQL on your Lightsail instance if it’s not installed yet. Learn how to install MySQL on AWS Lightsail.

Next, find the MySQL configuration file. The file name should be my.cnf 

Common possible paths where the file can be 

  • /etc/my.cnf
  • /etc/mysql/my.cnf
  • $MYSQL_HOME/my.cnf
  • [datadir]/my.cnf
  • ~/.my.cnf
  • /opt/bitnami/mysql/conf/my.cnf
  • /opt/bitnami/mariadb/conf/my.cnf

Don’t waste your time looking for every directory. You can find the configuration file using the command line. 

Run the command below

mysql --help

The output should be like this. 

Default options are read from the following files in the given order:

/opt/bitnami/mariadb/conf/my.cnf ~/.my.cnf


From the beginning of the output, you will get the configuration file link. Or you may also use this command. 

find . -name my.cnf

For Debian based Operating System, the file location is /opt/bitnami/mariadb/conf/my.cnf

Step 2: Updating MySQL Configuration 

By default MySQL Server only allows requests from the same server. Here, we need to rewrite the rule so that it accepts all anonymous request.

Run the command below.


For example:

nano /opt/bitnami/mariadb/conf/my.cnf

If returns permission is denied, you can alter the command like this.

sudo nano /opt/bitnami/mariadb/conf/my.cnf

The content of my.cnf file should appear in the terminal. Now replace the link below with the second one. 


Change to 


Simply comment in the bind_address variable; MySQL will skip this in the future. If you don’t want to allow anonymous requests, then simply add another line below with the IP address of your trusted server/application.


bind_address=XX.XX.XX.XX # replace XX with your trusted IP address.

Now press Ctrl + o to write down and then press Enter to save the file. Then press Ctrl + X to exit from the terminal. This part can be different for other distributions. Apply ordinary senses here.

Step 3: Restart Services 

To connect AWS Lightsail MySQL remotely, run the command below to restart all the Bitnami services like apache, MySQL, etc 

sudo /opt/bitnami/ctlscript.sh restart

The expected output is 

Restarting services…

Wait a minute. If no error returns, everything went well. Now you may close the terminal. 

Step 4: Open MySQL Port for IPv4 Firewall

Now it’s time to play with firewalls.

Go to the manage page of your instance. Goto Networking tab and scroll down to IPv4 Firewall 
4 Easy Steps to Connect AWS Lightsail MySQL Remotely

Click on Add a rule 

4 Easy Steps to Connect AWS Lightsail MySQL Remotely

Select MySQL/Aurora from the application list. The protocol should be TCP, and the port should be 3306 automatically. 

4 Easy Steps to Connect AWS Lightsail MySQL Remotely

For security reasons, you should restrict IP addresses for remote connections. 

Create the rule and reboot your instance by clicking on the Reboot button. 


Tada! You are ready now. Now you can connect AWS Lightsail MySQL Remotely.

Another useful article for AWS developers 10 reasons to use WP Dark Mode plugin on your site

Leave a Reply

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

Subscribe to get product updates

Get exclusive updates on discounts, product updates, WordPress news & tips