如何清除在CentOS 7上运行的mysqld.log文件

时间:2017-05-15 11:54:56

标签: mysql database logging centos7

我的mysqld.log文件很大,大约1.2GB,从2014年开始保存数据。如何从本月删除旧记录并仅保留记录?问题是我的数据库连续两天崩溃,恢复后没有再次启动。以下是日志文件的摘录:

170514 16:23:25 mysqld_safe Number of processes running now: 0
170514 16:23:25 mysqld_safe mysqld restarted
170514 16:23:25  InnoDB: Initializing buffer pool, size = 512.0M
170514 16:23:25  InnoDB: Completed initialization of buffer pool
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
170514 16:23:25  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
170514 16:23:25  InnoDB: Started; log sequence number 0 88464080
170514 16:23:25 [Note] Event Scheduler: Loaded 0 events
170514 16:23:25 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.1.73'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution

1 个答案:

答案 0 :(得分:0)

您必须访问mysql并检查二进制日志以使用以下命令决定您要删除的位置:     ls -la / var / lib / mysql /

您可能会得到一些这样的日志     -rw-rw ---- 1 mysql mysql 104871967 Aug 24 00:01 BINLOG.015687     -rw-rw ---- 1 mysql mysql 104885618 Aug 24 00:04 BINLOG.015688     -rw-rw ---- 1 mysql mysql 104866713 8月24日00:06 BINLOG.015689

然后在日期之前删除日志: 在2013-08-24 00:06:00';

之前的PURGE BINARY日志