標籤:二進位 資料庫 mysql 記錄
mysql二進位日誌:
命令列參數:
--log-bin[=file_name] 檔案名稱
--log-bin-index[=file]檔案索引
--max_binlog_size 單個檔案大小
--binlog-do-db=db_name對那些db記錄。只對指定資料庫進行記錄
--binlog-ignore-db=db_name忽略那些db。只忽略指定資料庫,其他資料庫記錄
系統變數:
log_bin
binlog_cache_size
max_binlog_cache_size
max_binlog_size
binlog_cache_use
binlog_cache_disk_use
binlog_do_db
binlog_ignore_db
sync_binlog
實驗:vim /etc/my.cnf
log-bin=/temp/binlog
log-bin-index=/temp/binlog.index
max-binlog-size=10M
binlog-do-db=test
先修改許可權 chown -R mysql.mysql temp
1、查看/temp下的檔案
2、show variables like ‘%max_binlog_size%‘;
3、use test;delete from test where id =31;
4、strings binlog.000002 =》delete from test where id =31
5、use mysql;delete from user where user=‘rep‘;
6、strings binlog.000002 =》 沒有
7、show binary logs;查看日誌 ;show master logs;手工日誌切換:flush logs;初始化日誌:reset master;
8、show variables like ‘%log_bin%‘;
9、select @@max_binlog_size;
binlog的格式:
binlog_format:STATEMENT,ROW,MIXED
set session binlog_format
set global binlog_format
ps -ef |grep mysql
show grants for [email protected];
grant all privileges on *.* to [email protected]‘%‘;
select user,password,host from mysql.user;
show variables like ‘%binlog_cache_size%‘; 當一個會話進來。先把日誌寫入記憶體、再寫到硬碟。。不是所有的會話。
select @@binlog_cache_size; 位元組為單位
select @@binlog_cache_size/1024; 32KB
show variables like ‘%max_binlog_size%‘; 記錄檔的大小。
select @@max_binlog_size/1024/1024; 單位MB
show status like ‘%binlog_cache_use%‘;
show status :可變的
show variables :不可變的。
本文出自 “老蔡” 部落格,請務必保留此出處http://877763363.blog.51cto.com/1200927/1671374
mysql二進位日誌。