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 root@localhost;
grant all privileges on *.* to cai@'%';
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 :不可變的。