![MySQL 无法启动,因为它找不到 mysql-bin.000006(错误代码 2),如何修复?](https://linux22.com/image/1357912/MySQL%20%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8%EF%BC%8C%E5%9B%A0%E4%B8%BA%E5%AE%83%E6%89%BE%E4%B8%8D%E5%88%B0%20mysql-bin.000006%EF%BC%88%E9%94%99%E8%AF%AF%E4%BB%A3%E7%A0%81%202%EF%BC%89%EF%BC%8C%E5%A6%82%E4%BD%95%E4%BF%AE%E5%A4%8D%EF%BC%9F.png)
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
您有两个选择:
将 mysql-bin.index 重命名为 mysql-bin.old。这样它就找不到该文件,但如果您需要它,您仍然可以使用它。
输入以下命令:
cp mysql-bin.000002 mysql-bin.000006
此后,您可以选择在运行此命令时将日期和时间更改为您想要的任何时间:
PURGE BINARY LOGS BEFORE '2013-03-14 10:00:00';