Mysql服务器重启报如下错误:
2023-06-14 16:21:15 4012 [Note] Plugin 'FEDERATED' is disabled.
2023-06-14 16:21:15 844 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.
2023-06-14 16:21:15 4012 [Note] InnoDB: Using atomics to ref count buffer pool pages
2023-06-14 16:21:15 4012 [Note] InnoDB: The InnoDB memory heap is disabled
2023-06-14 16:21:15 4012 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2023-06-14 16:21:15 4012 [Note] InnoDB: Compressed tables use zlib 1.2.3
2023-06-14 16:21:15 4012 [Note] InnoDB: Not using CPU crc32 instructions
2023-06-14 16:21:15 4012 [Note] InnoDB: Initializing buffer pool, size = 160.0M
2023-06-14 16:21:15 4012 [Note] InnoDB: Completed initialization of buffer pool
2023-06-14 16:21:15 4012 [Note] InnoDB: Highest supported file format is Barracuda.
InnoDB: No valid checkpoint found.
InnoDB: If this error appears when you are creating an InnoDB database,
InnoDB: the problem may be that during an earlier attempt you managed
InnoDB: to create the InnoDB data files, but log file creation failed.
InnoDB: If that is the case, please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/error-creating-innodb.html
2023-06-14 16:21:15 4012 [ERROR] Plugin 'InnoDB' init function returned error.
2023-06-14 16:21:15 4012 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2023-06-14 16:21:15 4012 [ERROR] Unknown/unsupported storage engine: INNODB
2023-06-14 16:21:15 4012 [ERROR] Aborting
网上有好多方法说删除这三个文件可以解决
删除ib_logfile*
删除ibdata*
但有重要的数据情况下这种方法不可行。。如有重要数据解决办法如下:
1.如果数据不重要或已经有备份,只需要恢复mysql启动
进入mysql目录,一般是:/usr/local/var/mysql/
删除ib_logfile*
删除ibdata*
删除所有数据库物理目录(例如数据库为test_db,则执行rm -rf test_db)
重启动mysql
重新建立数据库或使用备份覆盖
2.如果数据很重要且没有备份
可以使用innodb_force_recovery参数,使mysqld跳过恢复步骤,启动mysqld,将数据导出然后重建数据库。
innodb_force_recovery 可以设置为1-6,大的数字包含前面所有数字的影响
(SRV_FORCE_IGNORE_CORRUPT):忽略检查到的corrupt页。
(SRV_FORCE_NO_BACKGROUND):阻止主线程的运行,如主线程需要执行full purge操作,会导致crash。
(SRV_FORCE_NO_TRX_UNDO):不执行事务回滚操作。
(SRV_FORCE_NO_IBUF_MERGE):不执行插入缓冲的合并操作。
(SRV_FORCE_NO_UNDO_LOG_SCAN):不查看重做日志,InnoDB存储引擎会将未提交的事务视为已提交。
(SRV_FORCE_NO_LOG_REDO):不执行前滚的操作。
在my.cnf(windows是my.ini)中加入
innodb_force_recovery = 6
innodb_purge_thread = 0(purge多线程参数)
重启mysql
这时只可以执行select,create,drop操作,但不能执行insert,update,delete操作
执行逻辑导出,导出需要的数据库
完成后将innodb_force_recovery=0,innodb_purge_threads=1,(也可以去掉这两个配置)
然后重建数据库,最后把导出的数据重新导入