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.
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
Javeed Shaik · 14 February 2023 at 7:34 am
Is the process same for MS SQL? What are the changes have to be made to the above process?
Shinigami · 15 February 2023 at 11:44 am
It should be a bit easier with MS SQL as you can just enable tracing in SSMS connected to the container DB and use that to view the querries that have run.