mysql启动错误

service mysql start时报:ERROR! The server quit without updating PID file (/usr/local/mysql/data/mysql1.pid),错误。

1、查看error日志:

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!

发现是由于my.cnf这个文件配置错误导致的。

2、vim /etc/my.cnf

增加:

innodb_data_file_path=ibdata1:12M;ibdata2:10M:autoextend

参数要与已有的表空间一致,也就是/usr/local/mysql/data/目录下的文件size一致。或者直接删除掉ibdata1  ib_logfile0  ib_logfile1这三个文件也可。

再启动,发现还是报这个错误。

查看错误日志,提示:

[ERROR] InnoDB: Cannot start InnoDB. The tail of the system tablespace is missing. Have you edited innodb_data_file_path in my.cnf in an InnoDB: inappropriate way, removing ibdata files from there? You can set innodb_force_recovery=1 in my.cnf to force InnoDB: a startup if you are trying to recover a badly corrupt database.

是因为无法启动innodb造成的,按照提示设置:

innodb_force_recovery=1,使mysqld在启动时跳过恢复步骤。

innodb_force_recovery说明:

当设置参数值大于0后,可以对表进行select,create,drop操作,但insert,update或者delete这类操作是不允许的。

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):不执行前滚的操作。

启动mysql后重新设置innodb_force_recovery=0。

如果还是报错,那么:

修改my.cnf文件:

注释:

#pid-file=/var/run/mysqld/mysqld.pid

#socket=/var/lib/mysql/mysql.sock

这两行注释掉。

再启动,即可成功。

InnoDB: Header page consists of zero bytes in datafile: ./ibdata1, Space ID:

通常是由于初始化没有成功所造成的,确认配置文件正确。重新初始化。

posted @ 2018-01-30 13:07  叶落千尘  阅读(3356)  评论(0编辑  收藏  举报