MySQL內存不足的解決方法:
1、啟動MySQL時一直不成功,查看錯誤日志 /var/log/mysql/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、查詢后是因為內存不足,查看內存
增加swap交換空間解決問題:
dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile
4、增加自動掛載:
在文件/etc/fstab中加入 /swapfile swap swap defaults 0 0
service mysql start 啟動成功
5、備注:
生成空文件