mysql崩溃后进行重启
[root@mysql22-back ~]# service mysqld restart
Stopping mysqld: [ OK ]
Timeout error occurred trying to start MySQL Daemon.
Starting mysqld: [FAILED]
查看mysqld状态
[root@mysql22-back ~]# service mysqld status
mysqld dead but subsys locked
查看日志
tailf -20 /var/log/mysqld.log
2019-02-21T05:42:34.839336Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2019-02-21T05:42:34.839417Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2019-02-21T05:42:34.839443Z 0 [Note] InnoDB: Unable to open the first data file
2019-02-21T05:42:34.839500Z 0 [ERROR] InnoDB: Operating system error number 11 in a file operation.
2019-02-21T05:42:34.839588Z 0 [ERROR] InnoDB: Error number 11 means 'Resource temporarily unavailable'
2019-02-21T05:42:34.839623Z 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
2019-02-21T05:42:34.839649Z 0 [ERROR] InnoDB: Cannot open datafile './ibdata1'
2019-02-21T05:42:34.839679Z 0 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2019-02-21T05:42:34.839704Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Cannot open a file
2019-02-21T05:42:35.140042Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-02-21T05:42:35.140134Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-02-21T05:42:35.140162Z 0 [ERROR] Failed to initialize builtin plugins.
2019-02-21T05:42:35.140182Z 0 [ERROR] Aborting
尝试解决
杀死mysql进程
kill -9 mysql进程
移动文件
mv ibdata1 ibdata1.bak
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak
cp -a ibdata1.bak ibdata1
cp -a ib_logfile0.bak ib_logfile0
cp -a ib_logfile1.bak ib_logfile1
进行重启
[root@mysql22-back ~]# service mysqld restart
Stopping mysqld: [ OK ]
Timeout error occurred trying to start MySQL Daemon.
Starting mysqld: [FAILED]
再次查看日志
2019-02-21T06:24:52.584363Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2019-02-21T06:24:52.711484Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 210507159097
2019-02-21T06:24:52.711571Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 210507159106
2019-02-21T06:24:52.711599Z 0 [Note] InnoDB: Database was not shutdown normally!
2019-02-21T06:24:52.711617Z 0 [Note] InnoDB: Starting crash recovery.
日志显示正在恢复,进行等待即可
[root@mysql22-back ~]# service mysqld status
mysqld (pid 11178) is running...