mysql日誌詳細解析
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
mysql> SHOW GLOBAL VARIABLES LIKE '%log%';
+-----------------------------------------+-----------------------------------+
| Variable_name | Value |
+-----------------------------------------+-----------------------------------+
| back_log | 50 |
| binlog_cache_size | 32768 |
| binlog_direct_non_transactional_updates | OFF |
| binlog_format | MIXED |
| binlog_stmt_cache_size | 32768 |
| expire_logs_days | 0 |
| general_log | OFF |
| general_log_file | /mydata/data/stu18.log |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_buffer_size | 8388608 |
| innodb_log_file_size | 5242880 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | ./ |
| innodb_mirrored_log_groups | 1 |
| log | OFF |
| log_bin | ON |
| log_bin_trust_function_creators | OFF |
| log_error | /mydata/data/stu18.magedu.com.err |定義錯誤日誌
| log_output | FILE |
| log_queries_not_using_indexes | OFF |
| log_slave_updates | OFF |
| log_slow_queries | OFF |
| log_warnings | 1 是否把警告資訊寫入錯誤日誌中
| max_binlog_cache_size | 18446744073709547520 |
| max_binlog_size | 1073741824 |
| max_binlog_stmt_cache_size | 18446744073709547520 |
| max_relay_log_size | 0 |
| relay_log | |
| relay_log_index | |
| relay_log_info_file | relay-log.info |
| relay_log_purge | ON |
| relay_log_recovery | OFF |
| relay_log_space_limit | 0 |
| slow_query_log | OFF |
| slow_query_log_file | /mydata/data/stu18-slow.log |
| sql_log_bin | ON |
| sql_log_off | OFF |
| sync_binlog | 0 |
| sync_relay_log | 0 |
| sync_relay_log_info | 0 |
+-----------------------------------------+-----------------------------------+
|
1
2
3
|
[root@stu18 data]# vim /etc/my.cnf
[mysqld]
Log_error=DIR/[filename]
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
[root@stu18 data]# tail -20 stu18.magedu.com.err
130813 15:30:50 InnoDB: Starting shutdown...
130813 15:30:51 InnoDB: Shutdown completed; log sequence number 1630920
130813 15:30:51 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
130813 15:30:52 mysqld_safe mysqld from pid file /mydata/data/stu18.magedu.com.pid ended
130813 15:30:53 mysqld_safe Starting mysqld daemon with databases from /mydata/data
130813 15:30:54 InnoDB: The InnoDB memory heap is disabled #禁用了InnoDB memory的堆功能。
130813 15:30:54 InnoDB: Mutexes and rw_locks use GCC atomic builtins #Mutexes(互斥量)和rw_locks(行級鎖)是GCC編譯的是InnoDB內建的。
130813 15:30:54 InnoDB: Compressed tables use zlib 1.2.3 #預設壓縮工具是zlib
130813 15:30:55 InnoDB: Initializing buffer pool, size = 128.0M #InnoDB引擎的緩衝池(buffer pool)的值大小
130813 15:30:55 InnoDB: Completed initialization of buffer pool
130813 15:30:55 InnoDB: highest supported file format is Barracuda.
130813 15:30:57 InnoDB: Waiting for the background threads to start
130813 15:30:58 InnoDB: 5.5.33 started; log sequence number 1630920
130813 15:30:58 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
130813 15:30:58 [Note] - '0.0.0.0' resolves to '0.0.0.0'; #0.0.0.0會反解主機名,這裡反解失敗
130813 15:30:58 [Note] Server socket created on IP: '0.0.0.0'.
130813 15:30:58 [Note] Event Scheduler: Loaded 0 events #事件排程器沒有任何事件,因為沒有裝載。
130813 15:30:58 [Note] /usr/local/mysql/bin/mysqld: ready for connections. #mysql啟動完成等待客戶端的請求。
Version: '5.5.33-log' socket: '/tmp/mysql.sock' port: 3306 Source distribution #建立一個本地sock用於本地連線。
|
1
2
3
4
|
[root@stu18 data]# mv stu18.magedu.com.err stu18.magedu.com.err.old
[root@stu18 data]# mysqladmin flush-logs
[root@stu18 data]# ls
hellodb myclass mysql-bin.000003 mysql-bin.index stu18.magedu.com.pid ibdata1 mysql mysql-bin.000004 performance_schema ib_logfile0 mysql-bin.000001 stu18.magedu.com.err test ib_logfile1 mysql-bin.000002 stu18.magedu.com.err.old
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
mysql> SHOW GLOBAL VARIABLES LIKE '%log%';
+-----------------------------------------+-----------------------------------+
| Variable_name | Value |
+-----------------------------------------+-----------------------------------+
| back_log | 50 |
| binlog_cache_size | 32768 |
| binlog_direct_non_transactional_updates | OFF |
| binlog_format | MIXED |
| binlog_stmt_cache_size | 32768 |
| expire_logs_days | 0 |
| general_log | OFF #定義查詢日誌是否開啟 |
| general_log_file | /mydata/data/stu18.log #定義查詢日誌的檔案地址名稱 |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_buffer_size | 8388608 |
| innodb_log_file_size | 5242880 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | ./ |
| innodb_mirrored_log_groups | 1 |
| log | OFF #是否開啟日誌 (若開啟則表示開啟所有的日誌功能) |
| log_bin | ON |
| log_bin_trust_function_creators | OFF |
| log_error | /mydata/data/stu18.magedu.com.err |
| log_output | FILE #日誌的輸出的位置 |
| log_queries_not_using_indexes | OFF |
| log_slave_updates | OFF |
| log_slow_queries | OFF |
| log_warnings | 1 |
| max_binlog_cache_size | 18446744073709547520 |
| max_binlog_size | 1073741824 |
| max_binlog_stmt_cache_size | 18446744073709547520 |
| max_relay_log_size | 0 |
| relay_log | |
| relay_log_index | |
| relay_log_info_file | relay-log.info |
| relay_log_purge | ON |
| relay_log_recovery | OFF |
| relay_log_space_limit | 0 |
| slow_query_log | OFF |
| slow_query_log_file | /mydata/data/stu18-slow.log |
| sql_log_bin | ON |
| sql_log_off | OFF |
| sync_binlog | 0 |
| sync_relay_log | 0 |
| sync_relay_log_info | 0 |
+-----------------------------------------+-----------------------------------+
41 rows in set (0.00 sec)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
mysql> use mysql; #在此資料庫中
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log | #這個就是查詢日誌的表輸出位置
| help_category |
| help_keyword |
| help_relation |
| help_topic
……………… |
+---------------------------+
|
1
2
3
|
mysql> SHOW GLOBAL VARIABLES LIKE '%log%';
| slow_query_log | OFF #定義慢查詢日誌的
| slow_query_log_file |/mydata/data/stu18-slow.log #輸出方式為file(檔案)時定義慢查詢日誌的位置
|
1
2
3
4
|
[root@stu18 data]# vim /etc/my.cnf
[mysqld]
slow_query_log=1
log-slow-queries [= DIR/[filename] ]
|
1
2
3
4
5
6
7
|
mysql> SHOW GLOBAL VARIABLES LIKE 'long%';
+-----------------+-----------+
| Variable_name | Value |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+
1 row in set (0.04 sec)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
mysql> set globalslow_query_log=1; #開啟慢查詢日誌
Query OK, 0 rowsaffected (0.35 sec)
mysql> setsession long_query_time=0.001; #更改時間(當前session中,退出則重置)
Query OK, 0 rowsaffected (0.00 sec)
mysql> set globallong_query_time=0.001; #更改時間(全域性中,重啟服務則重置)
mysql> SHOWVARIABLES LIKE 'long%'; #查詢定義時間
+-----------------+----------+
| Variable_name | Value |
+-----------------+----------+
| long_query_time |0.001000 |
+-----------------+----------+
1 row in set (0.00sec)
mysql> showglobal variables like "%slow%"; #檢視慢查詢日誌開啟狀態
+---------------------+-----------------------------+
| Variable_name | Value |
+---------------------+-----------------------------+
|log_slow_queries | ON |
|slow_launch_time | 2 |
|slow_query_log | ON |
|slow_query_log_file | /mydata/data/stu18-slow.log |
+---------------------+-----------------------------+
4 rows in set (0.03sec)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
mysql> use mysql
mysql> selectuser,host,password from user where user="root";
+------+------------------+----------+
| user | host | password |
+------+------------------+----------+
| root |localhost | |
| root |stu18.magedu.com | |
| root |127.0.0.1 | |
| root | ::1 | |
+------+------------------+----------+
4 rows in set (0.08sec) #查詢時間為0.08
mysql> systemmore /mydata/data/stu18_slow.log #查詢慢查詢日誌記錄資訊
/usr/local/mysql/bin/mysqld,Version: 5.5.33-log (Source distribution). started
with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
>>>>>>>>>>>>>>>>部分已省略>>>>>>>>>>>>>>
# Time: 13100723:46:33
# User@Host:root[root] @ localhost []
# Query_time:0.108459 Lock_time: 0.000216 Rows_sent:4 Rows_examined: 6
SETtimestamp=1381160793;
selectuser,host,password from user where user="root";
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
mysql> SHOWGLOBAL VARIABLES LIKE '%log%';
+-----------------------------------------+-----------------------------------+
| Variable_name | Value |
+-----------------------------------------+-----------------------------------+
| innodb_flush_log_at_trx_commit | 1 #在事務提交時innodb是否同步日誌從緩衝到檔案中1表示事務以提交就同步不提交每隔一秒同步一次,效能會很差造成大量的磁碟I/O;定義為2表示只有在事務提交時才會同步但是可能會丟失整個事務 |
|innodb_locks_unsafe_for_binlog |OFF |
| innodb_log_buffer_size | 8388608 |
|innodb_log_file_size |5242880 |
| innodb_log_files_in_group | 2 #至少有兩個 |
|innodb_log_group_home_dir |./ #定義innodb事務日誌組的位置 |
|innodb_mirrored_log_groups |1 #表示對日誌組做映象 |
每個事務日誌都是大小為5兆的檔案:
[root@stu18 data]#ls -lh
-rw-rw---- 1 mysqlmysql 5.0M Oct 7 23:36 ib_logfile0
-rw-rw---- 1 mysqlmysql 5.0M Aug 12 01:06 ib_logfile1
|
1
2
3
4
5
6
7
8
|
mysql> showglobal variables like "%log_bin%";
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin | ON | #已開啟
|log_bin_trust_function_creators | OFF |
| sql_log_bin | ON |
+---------------------------------+-------+
|
1
2
3
4
5
6
7
8
9
10
|
mysql> showglobal variables like "%log%";
sql_log_bin ={ON|OFF} #用於控制會話級別二進位制日誌功能的開啟或關閉。預設為ON,表示啟用記錄功能。使用者可以在會話級別修改此變數的值,但其必須具有SUPER許可權。
binlog_cache_size =32768 #預設值32768 Binlog Cache用於在開啟了二進位制日誌(binlog)記錄功能的環境,是MySQL 用來提高binlog的記錄效率而設計的一個用於短時間內臨時快取binlog資料的記憶體區域。一般來說,如果我們的資料庫中沒有什麼大事務,寫入也不是特別頻繁,2MB~4MB是一個合適的選擇。但是如果我們的資料庫大事務較多,寫入量比較大,可與適當調高binlog_cache_size。同時,我們可以透過binlog_cache_use 以及 binlog_cache_disk_use來分析設定的binlog_cache_size是否足夠,是否有大量的binlog_cache由於記憶體大小不夠而使用臨時檔案(binlog_cache_disk_use)來快取了。
binlog_stmt_cache_size= 32768 #當非事務語句使用二進位制日誌快取,但是超出binlog_stmt_cache_size時,使用一個臨時檔案來存放這些語句。
log_bin = mysql-bin#指定binlog的位置,預設在資料目錄下。
binlog-format= {ROW|STATEMENT|MIXED} #指定二進位制日誌的型別,預設為MIXED。如果設定了二進位制日誌的格式,卻沒有啟用二進位制日誌,則MySQL啟動時會產生警告日誌資訊並記錄於錯誤日誌中。
sync_binlog = 10#設定多久同步一次二進位制日誌至磁碟檔案中,0表示不同步,任何正數值都表示對二進位制每多少次寫操作之後同步一次。當autocommit的值為1時,每條語句的執行都會引起二進位制日誌同步,否則,每個事務的提交會引起二進位制日誌同步
max_binlog_cache_size= {4096 .. 18446744073709547520} #二進定日誌快取空間大小,5.5.9及以後的版本僅應用於事務快取,其上限由max_binlog_stmt_cache_size決定。
max_binlog_stmt_cache_size= {4096 .. 18446744073709547520} #二進定日誌快取空間大小,5.5.9及以後的版本僅應用於事務快取
expire_log_days ={0..99} #設定二進位制日誌的過期天數,超出此天數的二進位制日誌檔案將被自動刪除。預設為0,表示不啟用過期自動刪除功能。如果啟用此功能,自動刪除工作通常發生在MySQL啟動時或FLUSH日誌時。
|
1
2
3
|
[root@stu18 ~]#my.cnf
[mysqld]
log-bin [=DIR \ [filename]]
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
[root@stu18 ~]# cd /mydata/data/
[root@stu18 data]#ls -lh
-rw-rw---- 1 mysqlmysql 14K Aug 13 15:30 mysql-bin.000001
-rw-rw---- 1 mysqlmysql 150 Aug 13 17:05 mysql-bin.000002
-rw-rw---- 1 mysqlmysql 150 Aug 13 17:06 mysql-bin.000003
-rw-rw---- 1 mysqlmysql 150 Aug 13 17:07 mysql-bin.000004
-rw-rw---- 1 mysqlmysql 150 Aug 13 17:39 mysql-bin.000005
-rw-rw---- 1 mysqlmysql 126 Aug 13 19:03 mysql-bin.000006
-rw-rw---- 1 mysqlmysql 126 Aug 13 19:03 mysql-bin.000007
-rw-rw---- 1 mysqlmysql 126 Aug 13 19:05 mysql-bin.000008
-rw-rw---- 1 mysqlmysql 107 Aug 13 19:05 mysql-bin.000009
-rw-rw---- 1 mysqlmysql 353 Oct 7 23:40 mysql-bin.000010
-rw-rw---- 1 mysqlmysql 190 Oct 7 20:43 mysql-bin.index
[root@stu18 data]#cat mysql-bin.index
./mysql-bin.000001
./mysql-bin.000002
./mysql-bin.000003
./mysql-bin.000004
./mysql-bin.000005
./mysql-bin.000006
./mysql-bin.000007
./mysql-bin.000008
./mysql-bin.000009
./mysql-bin.000010
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
mysql> showbinary logs; #顯示當前伺服器使用的二進位制檔案及大小
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001| 13814 |
| mysql-bin.000002| 150 |
| mysql-bin.000003| 150 |
| mysql-bin.000004| 150 |
| mysql-bin.000005| 150 |
| mysql-bin.000006| 126 |
| mysql-bin.000007| 126 |
| mysql-bin.000008| 126 |
| mysql-bin.000009| 107 |
| mysql-bin.000010| 353 |
+------------------+-----------+
10 rows in set (0.07sec)
mysql> showmaster logs; #顯示主伺服器使用的二進位制檔案及大小
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001| 13814 |
| mysql-bin.000002| 150 |
| mysql-bin.000003| 150 |
| mysql-bin.000004| 150 |
| mysql-bin.000005| 150 |
| mysql-bin.000006| 126 |
| mysql-bin.000007| 126 |
| mysql-bin.000008| 126 |
| mysql-bin.000009| 107 |
| mysql-bin.000010| 353 |
+------------------+-----------+
10 rows in set (0.02sec)
mysql> showmaster status; #當前使用的二進位制檔案及所處位置
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB |Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000010| 353 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00sec)
|
1
2
3
4
5
6
7
8
9
10
|
mysql> flushlogs;
Query OK, 0 rowsaffected (0.23 sec)
注意:flush logs一般只會滾動中繼日誌和二進位制日誌。
mysql> showmaster status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB |Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000011| 107 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00sec)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
mysql> createdatabase yong;
Query OK, 1 rowaffected (0.12 sec)
mysql> createtable yong.tb1 (id int,name char(20));
Query OK, 0 rowsaffected (0.44 sec)
mysql> insertinto yong.tb1 values(1,'tom');
Query OK, 1 rowaffected (0.14 sec)
mysql> showmaster status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB |Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000011| 479 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00sec)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
SHOW BINLOG EVENTS[IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]
mysql> showbinlog events\G #檢視所有的二進位制資訊
***************************87. row ***************************
Log_name: mysql-bin.000001
Pos: 13580
Event_type: Query
Server_id: 1
End_log_pos: 13688
Info: use `hellodb`; /*!40000 ALTERTABLE `toc` DISABLE KEYS */
***************************88. row ***************************
Log_name: mysql-bin.000001
Pos: 13688
Event_type: Query
Server_id: 1
End_log_pos: 13795
Info: use `hellodb`; /*!40000 ALTERTABLE `toc` ENABLE KEYS */
***************************89. row ***************************
Log_name: mysql-bin.000001
Pos: 13795
Event_type: Stop
Server_id: 1
End_log_pos: 13814
Info:
89 rows in set (0.00sec)
mysql> showbinlog events in 'mysql-bin.000011'; #檢視指定日誌的二進位制資訊
+------------------+-----+-------------+-----------+-------------+----------------------------------------------+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info |
+------------------+-----+-------------+-----------+-------------+----------------------------------------------+
| mysql-bin.000011| 4 | Format_desc | 1 | 107 | Server ver: 5.5.33-log, Binlogver: 4 |
| mysql-bin.000011 |107 | Query | 1 | 190 | create database yong |
| mysql-bin.000011 |190 | Query | 1 | 293 | create table yong.tb1 (idint,name char(20)) |
| mysql-bin.000011 |293 | Query | 1 | 357 | BEGIN |
| mysql-bin.000011 |357 | Query | 1 | 452 | insert into yong.tb1values(1,'tom') |
| mysql-bin.000011 |452 | Xid | 1 | 479 | COMMIT /* xid=103 */ |
+------------------+-----+-------------+-----------+-------------+----------------------------------------------+
6 rows in set (0.00sec)
mysql> showbinlog events in 'mysql-bin.000011' from 190; #從指定的事件位置開始
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
| Log_name | Pos | Event_type | Server_id |End_log_pos | Info |
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
| mysql-bin.000011 |190 | Query | 1 | 293 | create table yong.tb1 (idint,name char(20)) |
| mysql-bin.000011 |293 | Query | 1 | 357 | BEGIN |
| mysql-bin.000011 |357 | Query | 1 | 452 | insert into yong.tb1values(1,'tom') |
| mysql-bin.000011 |452 | Xid | 1 | 479 | COMMIT /* xid=103 */ |
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
4 rows in set (0.00sec)
mysql> showbinlog events in 'mysql-bin.000011' from 190 limit 3; #指定偏移量(不是語句,是事件)
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
| Log_name | Pos | Event_type | Server_id |End_log_pos | Info |
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
| mysql-bin.000011 |190 | Query | 1 | 293 | create table yong.tb1 (idint,name char(20)) |
| mysql-bin.000011 |293 | Query | 1 | 357 | BEGIN |
| mysql-bin.000011 |357 | Query | 1 | 452 | insert into yong.tb1values(1,'tom') |
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
3 rows in set (0.00sec)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@stu18 data]#mysqlbinlog mysql-bin.000017 #必須在資料目錄下
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET@@session.max_insert_delayed_threads=0*/;
/*!50003 SET@OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4 #事件開始處
#131009 0:25:59 server id 1 end_log_pos 107 Start: binlog v 4, server v 5.5.33-log created 131009 0:25:59
# Warning: thisbinlog is either in use or was not closed properly.
BINLOG '
FzJUUg8BAAAAZwAAAGsAAAABAAQANS41LjMzLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA==
'/*!*/;
# at 107
#131009 0:26:36 server id 1 end_log_pos 192 Query thread_id=12 exec_time=0 error_code=0 #131009 0:26:36年月日的簡寫方式;end_log_pos事件結束處;thread_id=12 哪個會話執行緒建立的此語句;exec_time=0 執行時長單位為秒;error_code=0 錯誤程式碼0表示沒有
SET TIMESTAMP=1381249596/*!*/; #預設資訊(環境設定)
|
1
|
[root@stu18 data]#mysqlbinlog mysql-bin.000017 > /tmp/a.sql
|
1
|
[root@stu18 data]#mysql < a.sql
|
1
2
3
4
5
6
7
8
9
|
mysql> resetmaster;
Query OK, 0 rowsaffected (0.17 sec)
mysql> showbinary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001| 107 |
+------------------+-----------+
1 row in set (0.04sec)
|
1
|
mysql> PURGE { BINARY | MASTER } LOGS {TO 'log_name' | BEFORE datetime_expr }
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
mysql> PURGEBINARY LOGS TO 'mysql-bin.000007';
Query OK, 0 rowsaffected (0.11 sec)
mysql> showbinary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000007| 150 |
| mysql-bin.000008| 150 |
| mysql-bin.000009| 150 |
| mysql-bin.000010| 150 |
| mysql-bin.000011| 150 |
| mysql-bin.000012| 150 |
| mysql-bin.000013| 150 |
| mysql-bin.000014| 150 |
| mysql-bin.000015| 150 |
| mysql-bin.000016| 150 |
| mysql-bin.000017| 483 |
+------------------+-----------+
11 rows in set (0.04sec)
[root@stu18 data]#cat mysql-bin.index
./mysql-bin.000007
./mysql-bin.000008
./mysql-bin.000009
./mysql-bin.000010
./mysql-bin.000011
./mysql-bin.000012
./mysql-bin.000013
./mysql-bin.000014
./mysql-bin.000015
./mysql-bin.000016
./mysql-bin.000017
|
1
2
|
mysql> PURGEBINARY LOGS BEFORE '13-10-19 10:26:36'; #使用時間來刪除二進位制日誌
Query OK, 0 rowsaffected (0.05 sec)
|
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30496894/viewspace-2079099/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ClickHouse(16)ClickHouse日誌引擎Log詳細解析
- MySQL慢日誌全解析MySql
- MySQL:排序(filesort)詳細解析MySql排序
- MySQL redo與undo日誌解析MySql
- MySQL索引機制(詳細+原理+解析)MySql索引
- mysql的日誌檔案詳解MySql
- 獲取Tomcat更詳細的日誌Tomcat
- mysql檢視binlog日誌詳解MySql
- mysql二進位制日誌詳解MySql
- MySQL複製應用中繼日誌解析MySql中繼
- Crash日誌解析
- mysql日誌MySql
- 2、MySQL錯誤日誌(Error Log)詳解MySqlError
- 【MySQL日誌】MySQL日誌檔案初級管理MySql
- mysql 日誌之錯誤日誌MySql
- mysql 日誌之慢查詢日誌MySql
- JVM GC日誌解析JVMGC
- mysql 日誌之普通查詢日誌MySql
- Mysql 日誌管理MySql
- MySQL(3)-日誌MySql
- MySQL 五 日誌MySql
- mysql清理日誌MySql
- mysql日誌管理MySql
- MYSQL日誌的正確刪除方法詳解MySql
- MySQL提升筆記(3)日誌檔案詳解MySql筆記
- MySQL日誌維護的7大策略詳解MySql
- mysqlbinlog工具基於日誌恢復詳細解釋MySql
- mysql 日誌之二進位制日誌MySql
- MYSQL啟用日誌和檢視日誌MySql
- CoreLocation框架詳細解析框架
- Semaphore最詳細解析
- RxLifecycle詳細解析
- SAP BOM詳細解析
- .NetCore中的日誌(1)日誌元件解析NetCore元件
- SQLite3原始碼學習(32) WAL日誌詳細分析SQLite原始碼
- 詳細講解刪除SQL Server日誌的具體方法SQLServer
- [MySQL binlog]徹底解析Mixed日誌格式的binlogMySql
- ELK構建MySQL慢日誌收集平臺詳解MySql