MySQL 配置了过大的内存导致无法启动:InnoDB: Cannot allocate memory for the buffer pool

问题描述
MySQL 启动时报错,查看错误日志有[ERROR] InnoDB: Cannot allocate memory for the buffer pool(不能从缓存池中分配给innodb引擎需要的内存)

解决办法
需要调整 MySQL 配置文件 my.cnf 中的 “innodb_buffer_pool_size”、”key_buffer_size” 的大小设置,适当的调大内存分配,一般调整为系统内存的一半

查询mysql日志如下:
MySQL 配置了过大的内存导致无法启动:InnoDB: Cannot allocate memory for the buffer pool

MySQL 配置了过大的内存导致无法启动:InnoDB: Cannot allocate memory for the buffer pool

我的做法是, 先查询服务器的内存..原来innodb_buffer_pool_size 的大小为256M的. 尔后把它调至512M后重启, 失败. 再分配128M后重启, 成功. 按照官方的说法是各一半的内存大小分配. 我想这应该是一个区间值, 反正, 就是多试….

查询下服务器的内存:
MySQL 配置了过大的内存导致无法启动:InnoDB: Cannot allocate memory for the buffer pool

命令 free -m 详解

total:内存总数;
used:已经使用的内存数;
free:空闲的内存数;
shared:当前已经废弃不用;
buffers Buffer:缓存内存数;
cached Page:缓存内存数。