Mysql 错误解决:Cannot open tablespace transaction_registry.ibd

今天自己的mysql数据库挂了,出现如下错误:

2018-11-22 16:19:12 17112 [Note] InnoDB: Memory barrier is not used
2018-11-22 16:19:12 17112 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-11-22 16:19:12 17112 [Note] InnoDB: Not using CPU crc32 instructions
2018-11-22 16:19:12 17112 [Note] InnoDB: Initializing buffer pool, size = 64.0M
2018-11-22 16:19:12 17112 [Note] InnoDB: Completed initialization of buffer pool
2018-11-22 16:19:13 17112 [Note] InnoDB: Highest supported file format is Barracuda.
2018-11-22 16:19:13 17112 [Note] InnoDB: The log sequence numbers 2243393 and 2243393 in ibdata files do not match the log sequence number 2243403 in the ib_logfiles!
2018-11-22 16:19:13 17112 [Note] InnoDB: Database was not shutdown normally!
2018-11-22 16:19:13 17112 [Note] InnoDB: Starting crash recovery.
2018-11-22 16:19:13 17112 [Note] InnoDB: Reading tablespace information from the .ibd files...
*********************************************************************
2018-11-22 16:19:13 17112 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace mysql/gtid_slave_pos uses space ID: 3 at filepath: .\mysql\gtid_slave_pos.ibd. Cannot open tablespace mysql/transaction_registry which uses space ID: 3 at filepath: .\mysql\transaction_registry.ibd
*********************************************************************
InnoDB: Error: could not open single-table tablespace file .\mysql\transaction_registry.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.

解决方法:
在my.cnf(windows是my.ini)的[mysql]节中中加入

innodb_force_recovery = 1

重启mysql,测试可以插入数据。
然后,再注释掉该语句,重启mysql正常!

你可能感兴趣的:(精进::Mysql)