Perfect solution to the problem of MySQL shutting down immediately after startup (caused by ibdata1 file corruption)

Perfect solution to the problem of MySQL shutting down immediately after startup (caused by ibdata1 file corruption)

The mysql on a server in the computer room had been running for a while, and suddenly a very strange phenomenon occurred: it could not be recovered after restarting! The exact situation is: after starting mysql, it is immediately closed again.

Check the mysql error log as follows:

160920 22:41:41 mysqld_safe Starting mysqld daemon with databases from /home/MysqlData/
2016-09-20 22:41:41 0 [Note] /Data/app/mysql5.6.25/bin/mysqld (mysqld 5.6.25-log) started as process 32372 ...
2016-09-20 22:41:42 32372 [Note] Plugin 'FEDERATED' is disabled.
2016-09-20 22:41:42 32372 [Warning] option 'innodb-write-io-threads': unsigned value 1000 adjusted to 64
2016-09-20 22:41:42 32372 [Warning] option 'innodb-read-io-threads': unsigned value 1000 adjusted to 64
2016-09-20 22:41:42 32372 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-09-20 22:41:42 32372 [Note] InnoDB: The InnoDB memory heap is disabled
2016-09-20 22:41:42 32372 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-09-20 22:41:42 32372 [Note] InnoDB: Memory barrier is not used
2016-09-20 22:41:42 32372 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-09-20 22:41:42 32372 [Note] InnoDB: Using CPU crc32 instructions
2016-09-20 22:41:42 32372 [Note] InnoDB: Initializing buffer pool, size = 1.0G
2016-09-20 22:41:42 32372 [Note] InnoDB: Completed initialization of buffer pool
2016-09-20 22:41:42 32372 [Note] InnoDB: Highest supported file format is Barracuda.
2016-09-20 22:41:42 32372 [Note] InnoDB: Log scan progressed past the checkpoint lsn 20293587957
2016-09-20 22:41:42 32372 [Note] InnoDB: Database was not shutdown normally!
2016-09-20 22:41:42 32372 [Note] InnoDB: Starting crash recovery.
2016-09-20 22:41:42 32372 [Note] InnoDB: Reading tablespace information from the .ibd files...
2016-09-20 22:41:42 32372 [Note] InnoDB: Restoring possible half-written data pages
2016-09-20 22:41:42 32372 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Doing recovery: scanned up to log sequence number 20293596130
2016-09-20 22:41:42 32372 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
InnoDB: Last MySQL binlog file position 0 136254, file name mysql-bin.000013
2016-09-20 22:41:43 32372 [Note] InnoDB: 128 rollback segment(s) are active.
2016-09-20 22:41:43 32372 [Note] InnoDB: Waiting for purge to start
2016-09-20 22:41:43 7f77a9edd700 InnoDB: Assertion failure in thread 140151928772352 in file trx0purge.cc line 699
InnoDB: Failing assertion: purge_sys->iter.trx_no <= purge_sys->rseg->last_trx_no
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
02:41:43 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

After analyzing the logs, we found that the database could not be restarted because the ibdata1 file was damaged and could not be restored normally after restart.

Solution:

You need to skip the recovery step , modify the my.cnf file, and add the following to [mysqld] in my.cnf:

innodb_force_recovery = 6
innodb_purge_threads = 1

explain:

innodb_force_recovery can be set to 1-6, with larger numbers including the effects of all previous numbers.

The meaning of the specific numbers:

1-----(SRVFORCEIGNORECORRUPT): Ignore the corrupt pages detected.
2-----(SRVFORCENOBACKGROUND): Prevents the main thread from running. If the main thread needs to perform a full purge operation, it will cause a crash.
3-----(SRVFORCENOTRXUNDO): Transaction rollback is not performed.
4-----(SRVFORCENOIBUFMERGE): Do not perform a merge operation on the insert buffer.
5-----(SRVFORCENOUNDOLOGSCAN): Without checking the redo log, the InnoDB storage engine will treat uncommitted transactions as committed.
6-----(SRVFORCENOLOG_REDO): Do not perform the rollforward operation.

Start mysql again and it will be ok~

If it still cannot be started, you need to delete files such as ibdata1, ib_logfile* in the data directory datafile.

After startup, export the MySQL database and restore it.

The above article perfectly solves the problem of MySQL closing immediately after startup (caused by ibdata1 file corruption) is all the content that the editor shares with you. I hope it can give you a reference, and I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • mysql-8.0.15-winx64 uses the zip package to install and the service is shut down immediately after starting
  • MySQL turns off password strength verification
  • How to disable foreign key constraint checking in MySQL child tables
  • How to open and close the MySQL database using mysqli object-oriented method in PHP
  • Tutorial on safely shutting down the MySQL service
  • How to turn off MySQL log to protect disk space under lnmp
  • Using batch processing to start and shut down mysql under Windows
  • How to open, close, and view function functions of MySQL database
  • Detailed explanation of MySQL shutdown process and methods to safely shut down MySQL
  • In-depth analysis of the definition, use and closing of Mysql cursors
  • Starting and shutting down the MySQL server
  • How to safely shut down a MySQL instance

<<:  Nginx location matching rule example

>>:  Based on vue-simple-uploader, encapsulate the global upload plug-in function of file segment upload, instant upload and breakpoint resume

Recommend

Detailed explanation of the difference between docker-compose ports and expose

There are two ways to expose container ports in d...

Examples of using provide and inject in Vue2.0/3.0

Table of contents 1. What is the use of provide/i...

How to embed other web pages in a web page using iframe

How to use iframe: Copy code The code is as follo...

JavaScript implements a box that follows the mouse movement

This article shares the specific code of JavaScri...

A brief discussion on which fields in Mysql are suitable for indexing

Table of contents 1 The common rules for creating...

Vue calls the computer camera to realize the photo function

This article example shares the specific code of ...

Vue implements two routing permission control methods

Table of contents Method 1: Routing meta informat...

Vue advanced usage tutorial dynamic components

Table of contents Basic description AST parsing R...

Automatically build and deploy using Docker+Jenkins

This article introduces Docker+Jenkins automatic ...

64-bit CentOs7 source code installation mysql-5.6.35 process sharing

First install the dependent packages to avoid pro...

Pure js to achieve typewriter effect

This article example shares the specific code of ...

Nginx merges request connections and speeds up website access examples

Preface As one of the best web servers in the wor...