简体   繁体   中英

How to clear mysqld.log file running on CentOS 7

My mysqld.log file is huge, about 1.2GB and saves data form 2014 up to now. How to remove old records and leave only records for example from this month? The problem is that two consecutive days my database crashed and not start again after recovery. Below is an excerpt from a log file:

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

You have to access mysql and Examine the binary logs to decide up to where you want to delete using the command: ls -la /var/lib/mysql/

You will probably get some logs like these -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 Aug 24 00:06 BINLOG.015689

Then you delete the logs before date : PURGE BINARY LOGS BEFORE '2013-08-24 00:06:00';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM