mysql二進位日誌。

來源:互聯網
上載者:User

標籤:二進位   資料庫   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二進位日誌。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.