MySQL因“致命错误”而停止,需要重新启动


MySQL stopped with a "Fatal Error" and requires restarting

我在数字海洋实例上托管一个WordPress站点,该实例是一个非托管云实例。我以前有时遇到一个问题,当我访问我的网站时,它说"未建立数据库连接"。因此,为了使它工作,我需要重新启动MySQL服务。

现在我再次遇到同样的错误,这个时间频率也很高。所以我去了错误日志,我认为这部分,我在这里粘贴指向问题:

    141123  3:15:39 InnoDB: The InnoDB memory heap is disabled
141123  3:15:39 InnoDB: Mutexes and rw_locks use GCC atomic builtins
141123  3:15:39 InnoDB: Compressed tables use zlib 1.2.3.4
141123  3:15:39 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(135987200 bytes) failed; errno 12
141123  3:15:39 InnoDB: Completed initialization of buffer pool
141123  3:15:39 InnoDB: Fatal error: cannot allocate memory for the buffer pool
141123  3:15:39 [ERROR] Plugin 'InnoDB' init function returned error.
141123  3:15:39 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
141123  3:15:39 [ERROR] Unknown/unsupported storage engine: InnoDB
141123  3:15:39 [ERROR] Aborting

所以我认为问题是因为它无法为缓冲池分配内存,并且由于这是致命错误,那么这可能是阻止MySQL的原因。但是我不知道如何解决它,这是导致问题的实际原因吗?那么它是否与服务器配置有关,或者我的代码中可能存在一些疯狂的查询?

更新

尝试修复@Sajidkhan后(以下答案之一)。Sill mysql 在一段时间后关闭,但这次日志有点不同。以下是我现在可以看到的。

141206 14:38:59 [Note] Plugin 'FEDERATED' is disabled.
141206 14:38:59 InnoDB: The InnoDB memory heap is disabled
141206 14:38:59 InnoDB: Mutexes and rw_locks use GCC atomic builtins
141206 14:38:59 InnoDB: Compressed tables use zlib 1.2.3.4
141206 14:38:59 InnoDB: Initializing buffer pool, size = 128.0M
141206 14:38:59 InnoDB: Completed initialization of buffer pool
141206 14:38:59 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
141206 14:38:59  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
141206 14:38:59  InnoDB: Waiting for the background threads to start
141206 14:39:00 InnoDB: 5.5.31 started; log sequence number 512843890

这里的关键是这一行:

141123  3:15:39 InnoDB: Fatal error: cannot allocate memory for the buffer pool

您应该尝试创建交换文件或升级到数字海洋上的下一个计划。

如果你真的需要skip-innodb(用例:低内存占用),那么你当然不必把它注释掉。但是,如果InnoDB是默认存储引擎,则服务器将无法启动,直到您告诉它使用哪个存储引擎,例如MyISAM的默认存储引擎=myisam。

试试这个:

sudo -u mysql mysqld --skip-innodb --default-storage-engine=myisam