LNMP 网站无法访问的解决方法

解决方案

问题说明

之前搭建基于 LNMP + WordPress 的博客,到目前为止出现过两次 Error establishing a database connection

无法访问网站

解决过程

// 2017.10.30

在排除了服务器的问题之后

初步推断是 MySQL 数据库连接的问题

查看 MySQL 日志

/var/log/mysqld.log 中发现以下

1
2
3
4
5
6
7
8
9
2017-10-30 11:49:45 9260 [ERROR] InnoDB: Cannot allocate memory for the buffer pool

2017-10-30 11:49:45 9260 [ERROR] Plugin 'InnoDB' init function returned error.

2017-10-30 11:49:45 9260 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

2017-10-30 11:49:45 9260 [ERROR] Unknown/unsupported storage engine: InnoDB

2017-10-30 11:49:45 9260 [ERROR] Aborting

根据日志搜索 MySQL 出现 InnoDB: Cannot allocate memory for the buffer pool

参考 解决MySQL : InnoDB: Cannot allocate memory for the buffer pool

有人也遇到了相同的问题

原因是给的内存不够

期间查看和重启 MySQL 都出错,各种方法都解决不了

/etc/my.conf 中做以下修改,并重启云主机

1
innodb_buffer_pool_size =256M

问题得到了解决。

// 2018.2.10

又出现相同的问题,由于把解决方案记录在博客上了,也没搜到合适的解决方案。

重启了一次云主机和 MySQL 问题得到了解决。

收获

网站能正常访问了

删除不必要的插件

做好备份 做好备份 做好备份

------ 本文结束------
如果对您有帮助的话请我喝瓶水吧!