Home  >  Article  >  Database  >  How to handle mysql innodb exception

How to handle mysql innodb exception

WBOY
WBOYforward
2023-04-17 21:01:061728browse

How to handle mysql innodb exception

1. Roll back and reinstall mysql

In order to avoid the trouble of importing this data from other places, first reinstall the current database Make a backup of the database file (/var/lib/mysql/location). Next, I uninstalled the Percona server 5.7 package, reinstalled the original 5.1.71 package, and started the mysql service. It prompted Unknown/unsupported table type: innodb and could not start normally.

110509 12:04:27 InnoDB: Initializing buffer pool, size = 384.0M
110509 12:04:27 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 157286400 bytes!
110509 12:04:27 [ERROR] Plugin 'InnoDB' init function returned error.
110509 12:04:27 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
110509 12:04:27 [ERROR] Unknown/unsupported table type: innodb
110509 12:04:27 [ERROR] Aborting
110509 12:04:27 [Note] /usr/sbin/mysqld: Shutdown complete

Delete the /var/lib/mysql/ directory, restart the database service, and initialize it. It is found to be normal. Show engines can find the innodb engine. Then stop the database, overwrite the contents of the previously backed up /var/lib/mysql/ directory with the contents of the current location, and restart. I also found that it could not be started, and the error content was the same as before.

The structure of the contents of the /var/lib/mysql directory is as follows:

-rw-rw---- 1 mysql mysql 10485760 2月 26 18:10 ibdata1
-rw-rw---- 1 mysql mysql 5242880 2月 26 18:10 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 2月 26 17:20 ib_logfile1
drwx------ 2 mysql mysql 4096 2月 26 17:20 mysql
drwx------ 2 mysql mysql 4096 2月 26 17:24 wiki

The wiki directory is the library for test data, the ibdata1 file is the data file, the two files starting with ib are log files, mysql The directory contains system library-related things. Use the initialized data again, and overwrite the wiki directory and ibdata1 file to the /var/lib/mysql directory. You can start normally and log in normally.

2. Reinstall the innodb module

However, when backing up through mysqldump, it prompts unknown table engine "Innodb". After logging in, check all the current engine types and find that the innodb type does not exist among them:

How to handle mysql innodb exception

Use the alter command to modify the type of one of the tables to MyISAM. , and found that an error was still reported.

How to handle mysql innodb exception

Through find, it is found that there is a ha_innodb_plugin.so file in the /usr/lib64/mysql/plugin/ directory. I have the impression that later versions of mysql5 support online plug-in installation. Check the following to confirm that it is indeed supported:

How to handle mysql innodb exception
##When using the following command to load, it was found that it was unsuccessful:

install plugin innodb soname 'ha_innodb.so';

3. Backup

In Add the following configuration to /etc/my.cnf:

plugin-load=innodb=ha_innodb_plugin.so
plugin_dir=/usr/lib64/mysql/plugin/
default-storage-engine=InnoDB

Found that the startup still failed. Check mysql-error.log and find the following content:

InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 7.
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
InnoDB: See also http://dev.mysql.com/doc/refman/5.1/en/forcing-innodb-recovery.html

Open the official forcing-innodb-recovery page and find that you can force startup and recovery by specifying the innodb_force_recovery parameter. Add the following content to /etc/my.cnf:

innodb_force_recovery=6

Restart successful. There is no problem with backing up through mysqldump. Importing the backup data to other hosts can also be found to be normal and can be tested.

Now it’s easy. Delete mysql completely and reinstall Percona server 5.7. After installation, build the database, restore the data, reconnect the program, and everything is OK.

The above is the detailed content of How to handle mysql innodb exception. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete