我刚刚从备份中恢复了我的 InnoDB 表(复制了 ibdata1、ib_logfile1、ib_logfile0)
然而,当我现在启动 mysql,并尝试使用 InnoDB 表访问我的网站时,*我收到这些错误
Got error -1 from storage engine
MySQL server has gone away
在我的 /var/log/syslog 中,我有很多类似的消息
Oct 19 00:21:31 vm645 mysqld: 111019 0:21:31 InnoDB: Error: page 113644 log sequence number 12 1381339343
Oct 19 00:21:31 vm645 mysqld: InnoDB: is in the future! Current system log sequence number 12 1375387790.
Oct 19 00:21:31 vm645 mysqld: InnoDB: Your database may be corrupt or you may have copied the InnoDB
Oct 19 00:21:31 vm645 mysqld: InnoDB: tablespace but not the InnoDB log files. See
Oct 19 00:21:31 vm645 mysqld: InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html
Oct 19 00:21:31 vm645 mysqld: InnoDB: for more information.
最后我看到
Oct 19 00:21:31 vm645 mysqld: InnoDB: Apply batch completed
Oct 19 00:21:31 vm645 mysqld: 111019 0:21:31 InnoDB: Started; log sequence number 12 1375387790
Oct 19 00:21:31 vm645 mysqld: InnoDB: !!! innodb_force_recovery is set to 4 !!!
Oct 19 00:21:31 vm645 mysqld: 111019 0:21:31 [Note] Event Scheduler: Loaded 0 events
Oct 19 00:21:31 vm645 mysqld: 111019 0:21:31 [Note] /usr/sbin/mysqld: ready for connections.
Oct 19 00:21:31 vm645 mysqld: Version: '5.1.49-3-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Debian)
好的,我想说它已准备好连接。但是,我得到了与这个问题开头所述的相同错误。它看起来已经启动了,但每次我尝试在 InnoDB 表上运行查询时,它都会崩溃一秒钟。
有什么想法吗?
编辑:
有时,当我重新启动 mysql 时,它会在控制台中显示
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
......
我必须重新开始
编辑2:
由于某种原因,现在它只抛出
Unknown table engine 'InnoDB'
答案1
我已经备份了所有数据库 ( mysqldump -p db_name > db_name.sql
),完全重新安装了 mysql 并重新导入了我的数据库 ( mysql -p db_name < db_name.sql
)。现在可以正常工作了。
附注:永远不要删除/var/lib/mysql/ibdata1
。
答案2
您是如何备份的?复制 mysql 目录是一个非常糟糕的主意,而且效果不佳。使用 mysqldump 或 innobackupex。
对于这个问题,可能解决你的问题的方法是将 ib_logfile[0|1] 移动到某个地方并启动 mysql 服务器。之后,我将开始检查数据库中的数据是否已损坏。