叨嗒嗵 - 慢查询
type: channel
link: https://www.dotatong.com/index.php/tag/慢查询/
items: Mysql开启查询日志、慢查询日志

Mysql开启查询日志、慢查询日志
type: item
date: 2020-09-09T07:45:00+00:00
description: 查询日志查看查询日志开启状态信息SHOW VARIABLES LIKE "general_log%";开启查询日志SET GLOBAL general_log='ON';指定查询日志存储路径SET GLOBAL general_log_file='/var/log/mysql/general_log.log';慢查询日志查看慢查询日志开启状态信息SHOW VARIABLES LIKE 'slow_query%';查看慢查询记录时间SHOW VARIABLES LIKE 'long_query_time';开启慢查询日志SET GLOBAL slow_query_log='ON';指定慢查询日志存储路径SET GLOBAL slow_query_log_file='/var/log/mysql/slow_log.log';指定慢查询记录时间SET GLOBAL long_query_time=2;日志存储方式存储至文件SET GLOBAL log_output = 'FILE';存储至表SET GLOBAL log_output = 'TABLE';