How to truncate the Slow Query Log on AWS RDS MySQL

I was in need to empty the slow_log table in MySQL database inside a Amazon Relational Database System to look into a performance issue. But I got the below error. I was surprised because I had login with the master user of the RDS.

mysql> use mysql

mysql> truncate table slow_log

Error Code: 1044. Access denied for user 'dbroot'@'%' to database 'mysql'

On surfing the internet I got this and it resolved my problem.

"Amazon RDS will not give you SSH access to its database server. That means you don’t have the opportunity to view any of the log files, even the slow query log, for the database. But RDS provides a way to play with the slow queries.

If your slow queries are many then this table will hold too many queries to handle. You cannot truncate the table or delete any row from there. There is only a way to move all the data from this table to another table named ‘slow_log_backup’, making the slow_log table empty. To do so you have to run a stored procedure already available in RDS.

Select the ‘mysql’ database and you can see some stored procedure listed. Run the procedure named ‘rds_rotate_slow_log’ by running CALL mysql.rds_rotate_slow_log command.

In the back-end RDS just renames those two tables, it does not actually move the data. Running the command twice will delete the slow log completely from the database server."


Excerpt from show tables

| slow_log                      |

| slow_log_backup               |


You can view the definition of the procedure by using the show create procedure ... statement.

For example: show create procedure mysql.rds_rotate_slow_log\G

Comments

Back To Top

Popular posts from this blog

How to save video from Internet Explorer

error 18 at 0 depth lookup: self signed certificate

How to check fragmentation in MySQL tables