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