MariaDB 쿼리 로그 남기기

# host에서 container로 진입
root@webgori-1:~# docker exec -it mariadb bash

root@1923623486a6:/# vi /etc/mysql/conf.d/log.cnf

[mysqld]
general_log = ON
general_log_file=/var/log/mysql/query.log

:wq

# host로 나와서 container 재시작
root@webgori-1:~# docker restart mariadb

# 로그를 확인하기 위해서 host에서 container로 진입
root@webgori-1:~# docker exec -it mariadb bash

# 로그 확인
root@1923623486a6:/# tail -f /var/log/mysql/query.log
240207 18:03:12      3 Connect  root@172.17.0.1 on laravel_api using TCP/IP
                     3 Query    use `laravel_api`
                     3 Prepare  set names 'utf8mb4' collate 'utf8mb4_unicode_ci'
                     3 Execute  set names 'utf8mb4' collate 'utf8mb4_unicode_ci'
                     3 Close stmt
                     3 Prepare  set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
                     3 Execute  set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
                     3 Close stmt
                     3 Prepare  select * from `users` where `users`.`id` = ? limit 1
                     3 Execute  select * from `users` where `users`.`id` = '1' limit 1
                     3 Close stmt
                     3 Prepare  select * from `users` limit 1
                     3 Execute  select * from `users` limit 1
                     3 Close stmt
                     3 Quit