MySQL8.0清空binlog

发布时间 2023-05-24 14:22:29作者: xjournal

环境

centos7.9

mysql  Ver 8.0.32

登录MySQL,查看binlog日志

#查看binlog日志开启状态,log_bin值为ON表示开启状态
mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin       | ON    |
+---------------+-------+
1 row in set (0.01 sec)
#查看binlog日志列表
mysql> show master logs;
+---------------+-----------+-----------+
| Log_name      | File_size | Encrypted |
+---------------+-----------+-----------+
| binlog.000001 |       157 | No        |
+---------------+-----------+-----------+
1 row in set (0.01 sec)
#刷新log日志,立刻产生一个新编号的binlog日志文件,跟重启一个效果 
mysql>flush logs;
Query OK, 0 rows affected (0.04 sec)
#再次查看binlog日志列表
mysql> show master logs;
+---------------+-----------+-----------+
| Log_name      | File_size | Encrypted |
+---------------+-----------+-----------+
| binlog.000001 |       201 | No        |
| binlog.000002 |       157 | No        |
+---------------+-----------+-----------+
2 rows in set (0.00 sec)
#清空所有binlog日志
mysql> reset master;
Query OK, 0 rows affected (0.03 sec)
#再次查看binlog日志列表
mysql> show master logs;
+---------------+-----------+-----------+
| Log_name      | File_size | Encrypted |
+---------------+-----------+-----------+
| binlog.000001 |       157 | No        |
+---------------+-----------+-----------+
1 row in set (0.00 sec)

关闭binlog可以从my.cnf文件中添加skip-log-bin