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

标签 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

最佳答案

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

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

然后删除 date 之前的日志: 在“2013-08-24 00:06:00”之前清除二进制日志;

关于mysql - 如何清除在 CentOS 7 上运行的 mysqld.log 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43978881/

相关文章:

mysql - 为什么 MySQL 使用 latin1_swedish_ci 作为默认值?

php - 使用 PHP 从字符串进行多个 MySQL 更新

mysql - 在 MySQL 中创建过程时如何使 ORDER BY 工作?

Mysql DATETIME相关查询 : how to calculate the expired entry?

heroku - 获取过去几周的 Heroku 日志

javascript - ionic + Genymotion : JavaScript logs

mysql - Drupal 7 db_select 嵌套选择查询

mongodb - 是否可以从查询中返回特定值的列表?

mysql - 在两个不同的数据库之间同步数据

azure - 具有多个应用程序的应用程序洞察