How to Enable Query(General Query) Log in Amazon RDS for MySQL?

Enable General Query Log in RDS for MySQL

How to Enable Query(General Query) Log in Amazon RDS for  MySQL?

Ever wondered how you can watch all the queries running in the database by someone? Here's how.

Let's Begin

Visit RDS console and choose the RDS instance. If the RDS instance is attached to a default parameter group, you have to create a new custom parameter group from the default parameter group.

After the custom parameter group is created, attach it to the RDS instance. Expect a downtime while you replace the existing parameter group. There won't be any downtime if you modify a parameter in the existing custom parameter group.

Modifying Parameter Group

1. Beginning with general_log. The default value will be disabled(0) or blank. Modify it to 1

2. Next parameter, log_output asks you where to save these logs, in this case I'm choosing file. The logs can be watched in real time or downloaded from the RDS console.

Click on Save Changes and wait for some time for the RDS to modify the parameter group.

Watching Logs

Choose Logs & Events tab. Scroll down and choose the general query log from Logs section and click on either Watch or Download.

When I ran a simple query in MySQL client, RDS logs it as in the given image.