The Amazon RDS ( AWS RDS ) – Managed relational database service from aws is a real blessing these days. Since its managed by aws, you don’t have to worry about the patching / administration / backups / restore aspects of it. All you need to do is upload the codes into it and make sure the connection between ec2 ( web-servers in this case ) and RDS is all good.

But, what if you want to manage the tables / dbs of the rds ? There is no way in which you can login into it directly and execute any codes.

You can make use of phpMyAdmin to login to the rds and manage it.

1) Install phpMyAdmin in the ec2-server ( Based on the linux distro it varies ) On a centos release, it comes with the EPEL Repository.

yum install epel-release ( installing the repo )
yum install phpmyadmin

2) Once installed, open the conf file at /etc/httpd/conf.d/phpMyAdmin.conf

You will find parameters which specify Require ip and Allow from which would be default to 127.0.0.1

3) Find your local public IP and replace the localhost entires with the public IP.

4) Restart the httpd service and make sure you can access phpMyAdmin at http://serverip/phpmyadmin.

If Step 3 is not done properly, you will get a 403 Forbidden error.

With this, the installations steps are complete, however, logging now to phpMyAdmin would give you only the option to manage the dbs on the local server now. To have the choice to connect to the RDS do the following :

1) Open the File – /etc/phpMyAdmin/config.inc.php ( on centos this would be the path )

2) Find the section –

/*
* End of servers configuration
*/

Just above it, type in the following :

$i++;
$cfg['Servers'][$i]['host'] = 'xxx.rds.amazonaws.com'; ( rds endpoint )
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['verbose'] = 'hostname'; ( hostname of the ec2 )
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = TRUE;

Save the config file. Now when you login to http://serverip/phpmyadmin/ you will get a dropdown to select the server, instead of localhost, select the server which we just added.

In case the above dropdown to select the server is not showing up, it would be a case of missing permissions / ownership.

Make sure the /etc/phpMyAdmin/ folder has the permission – 755
and the /etc/phpMyAdmin/config.inc.php file – 644

Note : The above was done on a virtualmin centos7 server.