1. 程式人生 > >《MySQL技術內幕:InnoDB儲存引擎》——第3章 檔案

《MySQL技術內幕:InnoDB儲存引擎》——第3章 檔案

引數檔案

mysql --help | grep my.cnf

mysql> show variables;//檢視引數

mysql> set read_buffer_size = 524288;//設定會話動態引數

mysql> set @@global.read_buffer_size = 524288;//設定全域性動態引數

日誌檔案

  • 錯誤日誌,記錄MySQL的啟動、執行、關閉過程

mysql> show variables like 'log_error';//路徑

  • 慢查詢日誌,可用於SQL語句優化

設定時間閾值:long_query_time

開關:slow_query_log

檔案路徑:slow_query_log_file

記錄沒有使用索引的SQL語句:log_queries_not_using_indexes

慢查詢輸出的格式:file/table

log_output 

  • 查詢日誌,記錄了所有對資料庫請求的資訊,不論這些資訊是否得到了正確的執行

general_log

general_log_file

  • 二進位制日誌,記錄了對資料庫執行更改的所有操作

開關:log_bin

log_bin_basename

log_bin_index

單個二進位制日誌檔案的最大值:max_binlog_size

binlog_cache_size

mysql> show global status like 'binlog_cache_use';

mysql> show global status like 'binlog_cache_disk_use';

sync_binlog

log_slave_updates//master->slave->slave

binlog_format

mysql> show master status;//二進位制日誌大小

mysqlbinlog mysql-bin.000001//檢視binlog

mysqlbinlog -vv mysql-bin.000001//檢視row型別的binlog

套接字檔案

mysql> show variables like "socket";

pid檔案

mysql> show variables like "pid_file";

表結構定義檔案

.frm

儲存引擎檔案

表空間檔案

mysql> show variables like "innodb_data_file_path";

mysql> show variables like "innodb_file_per_table";//.ibd

重做日誌檔案

mysql> show variables like "datadir";//檔案路徑

mysql> show create table xxxx;//顯示創表語句

mysql> show table status like "t1";//檢視當前表狀態

//linux下開啟ibd檔案

hexdump -C -v mytest.ibd > mytest.txt