Check MySQL logs in Docker environment

First, enter docker's MySQL container. Log in to the MySQL server and check the location of general_log as shown below.

mysql> show variables like 'general_log%';
+------------------+---------------------------------+
| Variable_name    | Value                           |
+------------------+---------------------------------+
| general_log      | OFF                             |
| general_log_file | /var/lib/mysql/55ca40b8744.log |
+------------------+---------------------------------+
2 rows in set (0.00 sec)

Since it is OFF, set it to ON. If you don't do this, the file doesn't seem to appear.

mysql> set global general_log = on;
Query OK, 0 rows affected (0.01 sec)

Go out of MySQL and go to var/lib/mysql. You can see it by referring to the contents of the file here.

root@55ca40b8744e:~# cd /var/lib/mysql
root@55ca40b8744e:/var/lib/mysql# cat 55ca40b8744.log 
Tcp port: 3306  Unix socket: /var/run/mysqld/mysqld.sock
Time                 Id Command    Argument
2020-12-18T17:18:27.044729+09:00	   26 Quit

Since I left the MySQL server earlier, it says that I have Quit.

The log when delete is tried is as follows.

2020-12-18T17:02:09.716428+09:00	   67 Prepare	DELETE FROM `TABLE` WHERE `table`.`id` = ?
2020-12-18T17:02:09.716513+09:00	   67 Execute	DELETE FROM `TABLE` WHERE `table`.`id` = 0

Recommended Posts

Check MySQL logs in Docker environment
Edit Mysql with commands in Docker environment
How to check the logs in the Docker container
MySQL 5.7 (Docker) environment construction memo
Rails + MySQL environment construction with Docker
Install laravel/Dusk in docker environment (laravel6)
[Environment construction with Docker] Rails 6 & MySQL 8
Alert slack with alert manager in Docker environment
SQL statement learning ~ Environment construction ~ Docker + MySQL
[Docker] Use environment variables in Nginx conf
Use docker in proxy environment on ubuntu 20.04.1
Create a MySQL environment with Docker from 0-> 1
MySQL container does not start in Docker
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Laravel + MySQL + phpMyadmin environment construction with Docker
Show Better Errors in Rails + Docker environment
Japanese setting of mysql in Docker container
Build TensorFlow operation check environment with Docker
[Environment construction] Rails + MySQL + Docker (Beginners can also use it in 30 minutes!)
Docker in LXD
Stumble in MySQL 5.5-> 5.7
Self-hosting with Docker of AuteMuteUs in Windows environment
Just install Laravel8 on docker in PHP8 environment
(Basic authentication) environment variables in rails and Docker
Rails6 [API mode] + MySQL5.7 environment construction with Docker
React + Django + Nginx + MySQL environment construction with Docker
Docker × Laravel HTTPS (SSL) communication in local environment
Migration error after Activerecord association in Rails5 + Docker environment (2)
How to install Docker in the local environment of an existing Rails application [Rails 6 / MySQL 8]
Points stuck when running vite + Nginx in Docker environment
virtulbox + vagrant + Docker + nginx + puma + MySQL Rails environment construction
Rails Docker environment construction
Build Docker + Laravel PHP + Vue.js development environment in 5 minutes
Migration error after Activerecord association in Rails5 + Docker environment
[Note] Build a Python3 environment with Docker in EC2
Dramatically speed up slow bundle install in docker environment
Command memo to install xeyes in ubuntu docker environment
[Docker] Connection with MySQL
SSL in the local environment of Docker / Rails / puma
Build Rails (API) x MySQL x Nuxt.js environment with Docker
Database environment construction with Docker in Spring boot (IntellJ)
Create a MySQL test environment (+ millions of test data) in 5 minutes
Install / run a standalone robot simulator in wsl2 / docker environment!
Install by specifying the version of Django in the Docker environment
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Express ~
Easy environment construction of MySQL and Redis with Docker and Alfred
Rails application development environment construction with Docker [Docker, Rails, Puma, Nginx, MySQL]
Exit code 1 occurs when Rails is stopped in Docker environment
[Docker context] ~ How to access docker in remote environment from VScode ~
Configuration script for using docker in proxy environment on ubuntu 20.04.1
Pytorch execution environment with Docker
WSL2 + VSCode + Docker development environment
[AWS] How to check logs
[Docker] Create Elasticsearch, Kibana environment!
Rails6 (MySQL, Ubuntu environment, Cloud9)
Install yarn in docker image
JavaFX environment construction in Java 13
Redmine (Docker) environment construction memo
I was suffering from panic: dial tcp 127.0.0.1: 3306: connect: connection refused in Go (Gin) + MySQL Docker environment
[Docker] Rails 5.2 environment construction with docker
Check https connection in Java