MySQL 启动时崩溃

MySQL crash on startup

我正在使用 wamp 在我的笔记本电脑上进行开发,mysql 运行 好几周了。今天在启动 mysql 后 60 秒后我崩溃了,并在日志中发现以下错误:

2016-03-17T20:34:37.662021Z 0 [ERROR] InnoDB: Cannot allocate 4294956804 bytes of memory after 60 retries over 60 seconds. OS error: Not enough space (12). Check if you should increase the swap file or ulimits of your operating system. Note that on most 32-bit computers the process memory space is limited to 2 GB or 4 GB.
2016-03-17 21:34:37 0x2b74  InnoDB: Assertion failure in thread 11124 in file ut0ut.cc line 938
InnoDB: Failing assertion: !m_fatal
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.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
20:34:37 UTC - mysqld got exception 0x80000003 ;
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.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.

key_buffer_size=67108864
read_buffer_size=2097152
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 685380 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x103288c0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
2016-03-17T20:34:37.682021Z 0 [ERROR] InnoDB: Cannot allocate 4294954524 bytes of memory after 60 retries over 60 seconds. OS error: Not enough space (12). Check if you should increase the swap file or ulimits of your operating system. Note that on most 32-bit computers the process memory space is limited to 2 GB or 4 GB.
2016-03-17 21:34:37 0x2b58  InnoDB: Assertion failure in thread 11096 in file ut0ut.cc line 938
InnoDB: Failing assertion: !m_fatal
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.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.

对我来说似乎存在内存问题:

[ERROR] InnoDB: Cannot allocate 4294956804 bytes of memory after 60 retries over 60 seconds. OS error: Not enough space (12).

难道是因为这个错误导致的崩溃? mysql 尝试分配 4Gb 的 ram 很奇怪,通常它使用或多或少的 500Mb。

这是my.ini:

innodb_buffer_pool_size = 16M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

我是 运行 mysql 32 位 win7 64 位。

这是我可以通过改变一些变量来解决的问题吗?

非常感谢您的帮助

这可能是 InnoDB 数据损坏。我添加了

innodb_force_recovery = 2

到my.ini,重新启动数据库,我能够转储所有数据并恢复它。

注意使用这个,之前阅读文档:http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html

我在 CentOS 上遇到了类似的问题 VPS,Stefano Giacone 的回答基本上就是我所做的,所以在经过数小时的研究和很大的压力后它成功了...

嗯,步骤是:

1) 找到 my.cnf 文件(我的位于 /etc/my.cnf)并添加行:

innodb_force_recovery = X

用 1 到 6 之间的整数替换 X,从 1 开始,如果 MySQL 无法启动则递增。设置为 4、5 或 6 可能会删除您的数据,因此请务必小心并阅读 http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html

2) 重新启动 MySQL 服务。只有 SELECT 会 运行,此时这是正常的。

3) 使用 mysqldump 将所有 databases/schemas 一个一个地转储,不要压缩转储,因为无论如何您都必须稍后在 6).

中解压缩它们

4) 仅移动(或删除!)/var/lib/mysql 中的 bd 目录,保留根目录中的单个文件。

5) 停止MySQL 然后取消注释1) 中添加的行。开始 MySQL.

6) 恢复在 3) 中转储的所有 bd)。

这对我有用,祝你好运!