[ERROR] InnoDB: Plugin initialization aborted with error Generic error几种报错#Olivia丶长歌#

时间:2024-04-07 07:55:27

1,mysql5.7无法启动,错误日志如下

[ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
[ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
[ERROR] InnoDB: Plugin initialization aborted with error Generic error
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Failed to initialize plugins.

[ERROR] InnoDB: Plugin initialization aborted with error Generic error几种报错#Olivia丶长歌#

目录用户权限问题,修改datadir属主属组

chown -R mysql:mysql ........

2,MySQL无法启动

2018-05-02T03:07:56.226901Z 0 [ERROR] InnoDB: Write to file ./ibtmp1failed at offset 9437184, 1048576 bytes should have been written, only 221184 were written. Operating system error number 28. Check that your OS and file system support files of this size. Check also that the disk is not full or a disk quota exceeded.

2018-05-02T03:07:56.226938Z 0 [ERROR] InnoDB: Error number 28 means 'No space left on device'

2018-05-02T03:07:56.226952Z 0 [Note] InnoDB: Some operating system error numbers are described at http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html

2018-05-02T03:07:56.226967Z 0 [ERROR] InnoDB: Could not set the file size of './ibtmp1'. Probably out of disk space

2018-05-02T03:07:56.226980Z 0 [ERROR] InnoDB: Unable to create the shared innodb_temporary

2018-05-02T03:07:56.226994Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error

2018-05-02T03:07:56.829843Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"

2018-05-02T03:07:56.829883Z 0 [ERROR] Plugin 'InnoDB' init function returned error.

2018-05-02T03:07:56.829897Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

2018-05-02T03:07:56.829912Z 0 [ERROR] Failed to initialize plugins.

2018-05-02T03:07:56.829922Z 0 [ERROR] Aborting

空间不足问题

mysql启动后又关闭。然后又自动重启,陷入了死循环。根本原因是空间不足。

df -h 查看下mysql所在的目录是不是100%

3,MySQL无法启动,报错如下

2018-06-17T16:31:15.959236+08:00 0 [Warning] InnoDB: innodb-page-size has been changed from the default value 16384 to 8192.
2018-06-17T16:31:15.959284+08:00 0 [Note] InnoDB: PUNCH HOLE support available
2018-06-17T16:31:15.959292+08:00 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-06-17T16:31:15.959297+08:00 0 [Note] InnoDB: Uses event mutexes
2018-06-17T16:31:15.959301+08:00 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-06-17T16:31:15.959306+08:00 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-06-17T16:31:15.959310+08:00 0 [Note] InnoDB: Using Linux native AIO
2018-06-17T16:31:15.959589+08:00 0 [Note] InnoDB: Number of pools: 1
2018-06-17T16:31:15.959656+08:00 0 [Note] InnoDB: Using CPU crc32 instructions
2018-06-17T16:31:15.960602+08:00 0 [Note] InnoDB: Initializing buffer pool, total size = 2G, instances = 8, chunk size = 128M
2018-06-17T16:31:16.109011+08:00 0 [Note] InnoDB: Completed initialization of buffer pool
2018-06-17T16:31:16.119766+08:00 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-06-17T16:31:16.129910+08:00 0 [ERROR] InnoDB: Data file './ibdata1' uses page size 16384, but the innodb_page_size start-up parameter is 8192

2018-06-17T16:31:16.129910+08:00 0 [ERROR] InnoDB: Data file './ibdata1' uses page size 16384, but the innodb_page_size start-up parameter is 8192
2018-06-17T16:31:16.129942+08:00 0 [ERROR] InnoDB: Corrupted page [page id: space=0, page number=0] of datafile './ibdata1' could not be found in the doublewrite buffer.
2018-06-17T16:31:16.129954+08:00 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2018-06-17T16:31:16.730466+08:00 0 [ERROR] Plugin 'InnoDB' init function returned error.
2018-06-17T16:31:16.730503+08:00 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-06-17T16:31:16.730518+08:00 0 [ERROR] Failed to initialize plugins.
2018-06-17T16:31:16.730525+08:00 0 [ERROR] Aborting

2018-06-17T16:31:16.730559+08:00 0 [Note] Binlog end
2018-06-17T16:31:16.730649+08:00 0 [Note] Shutting down plugin 'CSV'
2018-06-17T16:31:16.731019+08:00 0 [Note] /usr/sbin/mysqld: Shutdown complete

问题解决如下

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,大的数字包含前面所有数字的影响

  1. (SRV_FORCE_IGNORE_CORRUPT):忽略检查到的corrupt页。

  2. (SRV_FORCE_NO_BACKGROUND):阻止主线程的运行,如主线程需要执行full purge操作,会导致crash。

  3. (SRV_FORCE_NO_TRX_UNDO):不执行事务回滚操作。

  4. (SRV_FORCE_NO_IBUF_MERGE):不执行插入缓冲的合并操作。

  5. (SRV_FORCE_NO_UNDO_LOG_SCAN):不查看重做日志,InnoDB存储引擎会将未提交的事务视为已提交。

  6. (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,

然后重建数据库,最后把导出的数据重新导入。