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/data1/localhost.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/data1/localhost.localdomain.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/data1/localhost-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)
mysql> show global variables like 'log_error'; +---------------+-----------------------------------------+ | Variable_name | Value | +---------------+-----------------------------------------+ | log_error | /mydata/data1/localhost.localdomain.err | +---------------+-----------------------------------------+ 1 row in set (0.00 sec) mysql> show global variables like 'log_warnings'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_warnings | 1 | +---------------+-------+ 1 row in set (0.00 sec)
mysql> show global variables like 'general_log'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | general_log | OFF | +---------------+-------+ 1 row in set (0.00 sec) mysql> show global variables like 'general_log_file'; +------------------+-----------------------------+ | Variable_name | Value | +------------------+-----------------------------+ | general_log_file | /mydata/data1/localhost.log | +------------------+-----------------------------+ 1 row in set (0.01 sec)
mysql> set global general_log=1; Query OK, 0 rows affected (0.00 sec) mysql> show global variables like 'general_log'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | general_log | ON | +---------------+-------+ 1 row in set (0.00 sec)
mysql> show global variables like '%slow_query_log%'; +---------------------+----------------------------------+ | Variable_name | Value | +---------------------+----------------------------------+ | slow_query_log | OFF | | slow_query_log_file | /mydata/data1/localhost-slow.log | +---------------------+----------------------------------+ 2 rows in set (0.00 sec)
mysql> show global variables like 'long_query_time'; +-----------------+-----------+ | Variable_name | Value | +-----------------+-----------+ | long_query_time | 10.000000 | +-----------------+-----------+ 1 row in set (0.00 sec)
mysql> flush logs; Query OK, 0 rows affected (0.02 sec) mysql> show master status; #查看当前正在使用的二进制文件 +------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000033 | 107 | | | +------------------+----------+--------------+------------------+ 1 row in set (0.00 sec)
mysql> show binary logs; #查看所有的二进制文件
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000020 | 107 |
| mysql-bin.000021 | 107 |
| mysql-bin.000022 | 50676 |
| mysql-bin.000023 | 150 |
| mysql-bin.000024 | 621 |
| mysql-bin.000025 | 107 |
| mysql-bin.000026 | 4509 |
| mysql-bin.000027 | 150 |
| mysql-bin.000028 | 150 |
| mysql-bin.000029 | 150 |
| mysql-bin.000030 | 357 |
| mysql-bin.000031 | 107 |
| mysql-bin.000032 | 150 |
| mysql-bin.000033 | 107 |
+------------------+-----------+
14 rows in set (0.00 sec)
mysql> use mysql_shiyan;
Database changed
mysql> insert into department(dpt_name) values('feiyu');
Query OK, 1 row affected (0.00 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000033 | 331 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
mysql> insert into department(dpt_name) values('feiyu1'); #再插入一条数据
Query OK, 1 row affected (0.00 sec)
mysql> show binlog events in 'mysql-bin.000033'; #查看二进制文件中记录的内容
+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------------------------+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info |
+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------------------------+
| mysql-bin.000033 | 4 | Format_desc | 1 | 107 | Server ver: 5.5.36-log, Binlog ver: 4 |
| mysql-bin.000033 | 107 | Query | 1 | 183 | BEGIN |
| mysql-bin.000033 | 183 | Query | 1 | 304 | use `mysql_shiyan`; insert into department(dpt_name) values('feiyu') |
| mysql-bin.000033 | 304 | Xid | 1 | 331 | COMMIT /* xid=12 */ |
| mysql-bin.000033 | 331 | Query | 1 | 407 | BEGIN |
| mysql-bin.000033 | 407 | Query | 1 | 529 | use `mysql_shiyan`; insert into department(dpt_name) values('feiyu1') |
| mysql-bin.000033 | 529 | Xid | 1 | 556 | COMMIT /* xid=14 */ |
+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------------------------+
7 rows in set (0.00 sec)
mysql> show binlog events in 'mysql-bin.000033' from 407; #也可以从某个位置查看二进制文件
+------------------+-----+------------+-----------+-------------+-------------------------------------------------------------------------+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info |
+------------------+-----+------------+-----------+-------------+-------------------------------------------------------------------------+
| mysql-bin.000033 | 407 | Query | 1 | 529 | use `mysql_shiyan`; insert into department(dpt_name) values('feiyu1') |
| mysql-bin.000033 | 529 | Xid | 1 | 556 | COMMIT /* xid=14 */ |
+------------------+-----+------------+-----------+-------------+-------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> purge binary logs to 'mysql-bin.000025'; #删除某个序号之前的日志文件
Query OK, 0 rows affected (0.04 sec)
mysql> show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000025 | 107 |
| mysql-bin.000026 | 4509 |
| mysql-bin.000027 | 150 |
| mysql-bin.000028 | 150 |
| mysql-bin.000029 | 150 |
| mysql-bin.000030 | 357 |
| mysql-bin.000031 | 107 |
| mysql-bin.000032 | 150 |
| mysql-bin.000033 | 556 |
+------------------+-----------+
9 rows in set (0.00 sec)
←#4#root@localhost ~ →mysqlbinlog --start-position 407 --stop-position 556 mysql-bin.000033 /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; mysqlbinlog: File 'mysql-bin.000033' not found (Errcode: 2) DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
mysql> show global variables like 'innodb_flush_log_at_trx_commit'; +--------------------------------+-------+ | Variable_name | Value | +--------------------------------+-------+ | innodb_flush_log_at_trx_commit | 1 | +--------------------------------+-------+ 1 row in set (0.00 sec)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有