Mysql内存不足问题

1.启动MySQL时一直不成功,查看错误日志 /var/log/mysql/error.log

error.log

2.主要的错误信息有如下几条:

[ERROR] InnoDB: mmap(136151040 bytes) failed; errno 12
[ERROR] InnoDB: Cannot allocate memory for the buffer pool
[ERROR] InnoDB: Plugin initialization aborted with error Generic error
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Failed to initialize plugins.
[ERROR] Aborting

3.查询后是因为内存不足,查看内存:

free -h

增加swap交换空间解决问题:

dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile

4.增加自动挂载:

vim /etc/fstab
# 最后加入
/swapfile swap swap defaults 0 0

service mysql start 启动成功
发布了12 篇原创文章 · 获赞 57 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/qq_16166591/article/details/100622915