MySQL 无法启动,因为它找不到 mysql-bin.000006(错误代码 2),如何修复?

MySQL 无法启动,因为它找不到 mysql-bin.000006(错误代码 2),如何修复?

MySQL(属于磷酸二酯酶) 突然停止工作。查看mysql.err它说它无法启动,因为它找不到mysql-bin.000006(错误 2)。

以下是 mysql.err 的完整日志:

130401 17:00:47 InnoDB: The InnoDB memory heap is disabled
130401 17:00:47 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130401 17:00:47 InnoDB: Compressed tables use zlib 1.2.3
130401 17:00:47 InnoDB: Initializing buffer pool, size = 128.0M
130401 17:00:47 InnoDB: Completed initialization of buffer pool
130401 17:00:47 InnoDB: highest supported file format is Barracuda.
130401 17:00:49  InnoDB: Waiting for the background threads to start
130401 17:00:50 InnoDB: 1.1.8 started; log sequence number 193114266
/Applications/AMPPS/mysql/bin/mysqld: File './mysql-bin.000006' not found (Errcode: 2)
130401 17:00:50 [ERROR] Failed to open log (file './mysql-bin.000006', errno 2)
130401 17:00:50 [ERROR] Could not open log file
130401 17:00:50 [ERROR] Can't init tc log
130401 17:00:50 [ERROR] Aborting

130401 17:00:50  InnoDB: Starting shutdown...
130401 17:00:50  InnoDB: Shutdown completed; log sequence number 193114266
130401 17:00:50 [Note] /Applications/AMPPS/mysql/bin/mysqld: Shutdown complete

以下是所有二进制日志文件所在的目录:

drwx------  128 cyberskull  admin      4352 Mar 31 02:46 redacted
-rw-rw----    1 cyberskull  admin   5242880 Apr  1 17:00 ib_logfile0
-rw-rw----    1 cyberskull  admin   5242880 Mar 31 02:46 ib_logfile1
-rw-rw----    1 cyberskull  admin  44040192 Apr  1 17:00 ibdata1
drwxr-xr-x@  74 cyberskull  admin      2516 Jan 30 22:31 mysql
-rw-rw----    1 cyberskull  admin   2053929 Mar 18 23:18 mysql-bin.000001
-rw-rw----    1 cyberskull  admin  44002874 Mar 23 19:40 mysql-bin.000002
-rw-rw----    1 cyberskull  admin  25182139 Mar 25 20:59 mysql-bin.000003
-rw-rw----    1 cyberskull  admin  21533910 Mar 28 19:51 mysql-bin.000004
-rw-rw----    1 cyberskull  admin  32820396 Mar 29 18:45 mysql-bin.000005
-rw-rw----    1 cyberskull  admin       114 Mar 30 14:33 mysql-bin.index
-rw-rw----@   1 cyberskull  admin    114303 Apr  1 17:00 mysql.err
drwxr-xr-x@  20 cyberskull  admin       680 Jan 30 22:31 performance_schema
drwxr-xr-x@   2 cyberskull  admin        68 Jan 30 22:31 test

我要做什么才能使 MySQL 重新启动并运行?

答案1

选项1

只需将二进制日志移到一边并启动mysql

mv mysql-bin.* ..

然后,启动mysql

选项 #2

编辑文件mysql-bin.index并删除以下行mysql-bin.0000006

然后,启动mysql

试一试 !!!

答案2

您有两个选择:

  1. 将 mysql-bin.index 重命名为 mysql-bin.old。这样它就找不到该文件,但如果您需要它,您仍然可以使用它。

  2. 输入以下命令:

    cp mysql-bin.000002 mysql-bin.000006
    

    此后,您可以选择在运行此命令时将日期和时间更改为您想要的任何时间:

    PURGE BINARY LOGS BEFORE '2013-03-14 10:00:00';
    

相关内容