If you’ve got a MySQL database running in Docker and you want to debug the calls being made to it you can enable logging and then export those logs to your desktop for investigation.

First you need to enable logging in your MySQL database.

SET global general_log = on;
SET global general_log_file='/var/log/mysql/mysql.log';
SET global log_output = 'file';

Then if you trigger the action that access the database it will be captured to the referenced log file.

In order to be able to export the log file you need to first get the ID (PID) of the container.

docker ps

Then you can copy it to your desktop.

docker cp <PID>:/var/log/mysql/mysql.log /Users/<USERNAME>/Downloads/sql.log

Once that’s done you’ll wnat to disable logging so it doesn’t grow too large.

SET global general_log = off;

You can then delete the log file from Docker.

docker exec <PID> rm -rf /var/log/mysql/mysql.log

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.