Login
网站首页 > 文章中心 > 其它

自动清理MySQL_binlog日志_mysql binlog清理

作者:小编 更新时间:2023-08-08 13:06:13 浏览量:138人看过

开启MySQL?binlog日志的服务器,如果不设置自动清理日志,默认binlog日志一直保留着,时间一长,服务器磁盘空间被binlog日志占满,导致MySQL数据库出错.

使用下面方法可以安全清理binlog日志

第一段:没有主从同步的情况下清理日志

mysql -u root -p ?#进入mysql 控制台

reset master; ?#重置binlog

第二段:MySQL主从同步下安全清理binlog日志

①.、mysql ?-u root -p ?#进入从服务器mysql控制台

自动清理MySQL_binlog日志_mysql binlog清理-图1

show slave status\G; ?#检查从服务器正在读取哪个日志,有多个从服务器,选择时间最早的一个做为目标日志.

show master log; ?#获得主服务器上的一系列日志

第三段:设置自动清理MySQL binlog日志

log-bin=mysql-bin ?#注释掉之后,会关闭binlog日志

binlog_format=mixed ?#注释掉之后,会关闭binlog日志

:wq! ?#保存退出

扩展阅读:

help purge;

Description:

Syntax:

PURGE { BINARY | MASTER } LOGS

The binary log is a set of files that contain information about data

modifications made by the MySQL server. The log consists of a set of

binary log files, plus an index file (see

The PURGE BINARY LOGS statement deletes all the binary log files listed

in the log index file prior to the specified log file name or date.

BINARY and MASTER are synonyms. Deleted log files also are removed from

the list recorded in the index file, so that the given log file becomes

the first in the list.

This statement has no effect if the server was not started with the

Examples:

以上就是土嘎嘎小编为大家整理的自动清理MySQL_binlog日志相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章