mysql - 使用general-log 来查看所有的SQL语句
访问量: 1150
在diesel框架中, 不像rails那样会打印出所有的SQL,貌似该框架也没实现这个功能,所以在特别需要的时候,需要在本地开发环境打印SQL
1. 修改配置文件
# # * Logging and Replication # # Both location gets rotated by the cronjob. # Be aware that this log type is a performance killer. # As of 5.1 you can enable the log at runtime! general_log_file = /var/log/mysql/mysql.log general_log = 1
2. 重启
3. 查看结果: tail /var/log/mysql.log -f
2020-05-01T11:50:19.780187Z 2 Query SELECT st.* FROM performance_schema.events_statements_current st JOIN performance_schema.threads thr ON thr.thread_id = st.thread_id WHERE thr.processlist_id = 3 2020-05-01T11:50:19.780857Z 2 Query SELECT st.* FROM performance_schema.events_stages_history_long st WHERE st.nesting_event_id = 16 2020-05-01T11:50:19.781260Z 2 Query SELECT st.* FROM performance_schema.events_waits_history_long st WHERE st.nesting_event_id = 16 2020-05-01T11:50:19.784533Z 2 Query SHOW INDEX FROM `cadae`.`accounts`