MySQL 有关“InnoDB: Error: log file ib_logfile0 is of different size 0 5242880 bytes”错误

1,查看Mysqld mysql.err 日志,发现以下错误:

150811 08:51:02 mysqld_safe Starting mysqld daemon with databases from /home/mysql/var
150811  8:51:02 [Warning] The syntax ‘–log-slow-queries’ is deprecated and will be removed in a future release. Please use ‘–slow
-query-log’/’–slow-query-log-file’ instead.
150811  8:51:02 InnoDB: The InnoDB memory heap is disabled
150811  8:51:02 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150811  8:51:02 InnoDB: Compressed tables use zlib 1.2.3
150811  8:51:02 InnoDB: Initializing buffer pool, size = 256.0M
150811  8:51:02 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file /home/mysql/var/ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 67108864 bytes!
150811  8:51:02 [ERROR] Plugin ‘InnoDB’ init function returned error.
150811  8:51:02 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed.
150811  8:51:02 [ERROR] Unknown/unsupported storage engine: InnoDB
150811  8:51:02 [ERROR] Aborting
150811  8:51:02 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
150811 08:51:02 mysqld_safe mysqld from pid file /home/mysql/var/centos.pid ended

2,解决办法

If you want to change the number or the size of your InnoDB log files, you
have to shut down MySQL and make sure that it shuts down without errors.
Then copy the old log files into a safe place just in case something went
wrong in the shutdown and you will need them to recover the database. Delete
then the old log files from the log file directory, edit my.cnf, and start
MySQL again. InnoDB will tell you at the startup that it is creating new log
files.

在你修改my.cnf的innodb_log_file_size参数前,请先停止mysql服务程序的运行(mysql的停止没有出现任何错误),并把/var/lib/mysql目录下的ib_logfile0、ib_logfile1、ib_logfile2等之类的文件移除到一个安全的地方(旧日志文件的保留是为了防止意外的出现),以便Mysql重启后可以将新的ib_logfile0之类日志文件生成到/var/lib/mysql目录下。如果没有什么意外,旧的日志文件可以删除。