Connect to AWS RDS MySQL Using phpMyAdmin With AWS Lightsail Ubuntu

Connect to AWS RDS MySQL Using phpMyAdmin With AWS Lightsail Ubuntu

A guide on how to connect to an AWS RDS MySQL instance using phpMyAdmin

Amazon Web Services (AWS) is a cloud computing platform that provides a wide range of services, including Relational Database Service (RDS), which allows you to set up, operate, and scale a relational database in the cloud. One of the most popular database engines on RDS is MySQL, an open-source database management system.

In this article, I'll show you how to connect to an AWS RDS MySQL instance using phpMyAdmin, a web-based interface for managing MySQL databases. We'll be using an AWS Lightsail Ubuntu instance as our local development environment.

Prerequisites

  • An AWS account with RDS and Lightsail access

  • A running RDS MySQL instance

  • An AWS Lightsail Ubuntu instance

  • A web browser

  • An SSH client

Step 1: Install phpMyAdmin

The first step is to install phpMyAdmin on your AWS Lightsail Ubuntu instance. You can do this by running the following command:

sudo apt-get update
sudo apt-get install phpmyadmin

During the installation process, you'll be prompted to choose a web server to configure. Select "apache2" and press enter.

Next, you'll be asked if you want to configure the database for phpmyadmin with dbconfig-common. Select "Yes" and enter the password for the MySQL root user.

Step 2: Configure Apache

By default, phpMyAdmin is only accessible from the localhost. To make it accessible from your browser, you need to configure Apache.

Open the Apache configuration file using the following command:

sudo nano /etc/apache2/conf-available/phpmyadmin.conf

Add the following lines to the bottom of the file:

# phpMyAdmin Configuration
Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php

    <IfModule mod_php7.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_admin_flag allow_url_fopen Off
        php_value include_path .
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/javascript/
    </IfModule>

    <IfModule mod_authz_core.c>
        <RequireAny>
            Require all granted
        </RequireAny>
    </IfModule>

</Directory>

Save and close the file using Ctrl + X, Y, and Enter.

Next, enable the configuration file and restart Apache:

sudo a2enconf phpmyadmin.conf
sudo systemctl reload apache2

Step 3: Connect to RDS MySQL

Now that phpMyAdmin is installed and configured, you can use it to connect to your RDS MySQL instance.

Open your web browser and navigate to your Lightsail Ubuntu instance's IP address followed by "/phpmyadmin" (e.g., 11.22.33.44/phpmyadmin). You'll be prompted to enter your MySQL username and password.

Enter the MySQL username and password for your RDS MySQL instance, and click "Go." You should now be connected to your RDS MySQL instance using phpMyAdmin.

Conclusion In this blog, I showed you how to connect to an AWS RDS MySQL instance using phpMyAdmin with an AWS Lightsail Ubuntu instance. By following these steps, you can easily manage your MySQL databases in the cloud, without the need for additional software installations on your local machine. This method is particularly useful if you need to manage your MySQL databases remotely, from any location. Keep in mind that phpMyAdmin is just one of many tools available for managing MySQL databases on AWS, and depending on your needs, you may want to explore other options such as the AWS Management Console, MySQL Workbench, or command-line tools. With this knowledge, you can confidently connect to your AWS RDS MySQL instance using phpMyAdmin and manage your databases with ease.