How to link phpMyAdmin to an AWS RDS MySQL Instance

To connect phpMyAdmin with an AWS RDS MySQL Instance, you can follow these steps:


1. Launch an EC2 instance and install Apache, PHP, and phpMyAdmin on it.

2. In the AWS RDS console, go to the "Security Groups" section and create a new security group that allows inbound traffic on port 3306 from the IP address of your EC2 instance.

3. Go to the "Parameter Groups" section and create a new parameter group with the following settings:

   - log_bin_trust_function_creators = 1

   - lower_case_table_names = 1

4. Modify your RDS instance to use the new parameter group you just created.

5. In phpMyAdmin, go to the "config.inc.php" file and add the following lines at the end:


   $cfg['Servers'][$i]['host'] = 'your_rds_endpoint';

   $cfg['Servers'][$i]['port'] = '3306';

   $cfg['Servers'][$i]['user'] = 'your_rds_username';

   $cfg['Servers'][$i]['password'] = 'your_rds_password';


Replace "your_rds_endpoint", "your_rds_username", and "your_rds_password" with your actual RDS endpoint, username, and password.

6. Save the "config.inc.php" file and restart Apache.

You should now be able to access your AWS RDS MySQL database through phpMyAdmin.

Explaination of below lines :

$i++; 

$cfg['Servers'][$i]['host'] = '';

$cfg['Servers'][$i]['compress'] = false;

$cfg['Servers'][$i]['AllowNoPassword'] = false;

$cfg['Servers'][$i]['connect_type'] = 'tcp';

$cfg['Servers'][$i]['extension'] = 'mysqli';

$cfg['Servers'][$i]['port'] = ''; 

$cfg['Servers'][$i]['user'] = '';

$cfg['Servers'][$i]['password'] = '';


___

1. `$i++;`

This line increments the value of the `$i` variable by 1. This is often used as a way to keep track of the number of servers or iterations in a loop.

2. `$cfg['Servers'][$i]['host'] = '';`

This line sets the value of the `host` key in the `$cfg['Servers'][$i]` sub-array to an empty string. This key represents the hostname or IP address of the MySQL server that the PHP script is connecting to.

3. `$cfg['Servers'][$i]['compress'] = false;`

This line sets the value of the `compress` key in the `$cfg['Servers'][$i]` sub-array to `false`. This key represents whether the script should use compression when communicating with the MySQL server.

4. `$cfg['Servers'][$i]['AllowNoPassword'] = false;`

This line sets the value of the `AllowNoPassword` key in the `$cfg['Servers'][$i]` sub-array to `false`. This key represents whether the MySQL server allows connections without a password. Setting this to `false` ensures that a password is required to connect to the server.

5. `$cfg['Servers'][$i]['connect_type'] = 'tcp';`

This line sets the value of the `connect_type` key in the `$cfg['Servers'][$i]` sub-array to `'tcp'`. This key represents the type of connection that the PHP script should use to connect to the MySQL server. `'tcp'` is the most common type of connection.

6. `$cfg['Servers'][$i]['extension'] = 'mysqli';`

This line sets the value of the `extension` key in the `$cfg['Servers'][$i]` sub-array to `'mysqli'`. This key represents the PHP extension that should be used for the database connection. `'mysqli'` is a commonly used extension for MySQL connections.

7. `$cfg['Servers'][$i]['port'] = '';`

This line sets the value of the `port` key in the `$cfg['Servers'][$i]` sub-array to an empty string. This key represents the port number that the MySQL server is listening on. If left empty, the default MySQL port (3306) will be used.

8. `$cfg['Servers'][$i]['user'] = '';`

This line sets the value of the `user` key in the `$cfg['Servers'][$i]` sub-array to an empty string. This key represents the username that should be used to connect to the MySQL server.

9. `$cfg['Servers'][$i]['password'] = '';`

This line sets the value of the `password` key in the `$cfg['Servers'][$i]` sub-array to an empty string. This key represents the password that should be used to connect to the MySQL server. If left empty, the PHP script will prompt the user for a password when attempting to connect to the server.