mysql 全局日志(general_log)详解


基本命令

查看日志是否开启

show variables like 'general_log';

开启日志功能

set global general_log=on;

查看日志文件保存位置

show variables like 'general_log_file';

设置日志文件保存位置

set global general_log_file='/tmp/mysql_general.log';

查看日志输出类型 table或file

show variables like 'log_output';

设置输出类型为 table

set global log_output='table';

设置输出类型为file

set global log_output='file';

开启数据库general_log步骤

set global general_log=on;
set global log_output='file';
set global general_log_file='/tmp/mysql_general.log';
sudo cat /tmp/mysql_general.log
/usr/sbin/mysqld, Version: 8.0.25-0ubuntu0.20.04.1 ((Ubuntu)). started with:
Tcp port: 3306  Unix socket: /var/run/mysqld/mysqld.sock
Time                 Id Command    Argument
2021-07-18T08:53:04.925394Z       46 Query    SELECT DATABASE()
2021-07-18T08:53:04.925630Z       46 Init DB    school_info
2021-07-18T08:53:04.926313Z       46 Query    show databases
2021-07-18T08:53:04.927244Z       46 Query    show tables
2021-07-18T08:53:04.928407Z       46 Field List    class 
2021-07-18T08:53:04.928536Z       46 Field List    lock_myisam 
2021-07-18T08:53:04.928677Z       46 Field List    school 
2021-07-18T08:53:04.928762Z       46 Field List    student 
2021-07-18T08:53:04.928853Z       46 Field List    test5 
2021-07-18T08:53:06.874598Z       46 Query    select * from student where id=1
2021-07-18T08:53:08.992675Z       46 Quit    


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM