mysql挂掉解决办法InnoDB: Cannot allocate memory for the buffer pool

Google-Adsense

通常来说就是你内存小了,如果不能扩内存,就用swap。
报错信息如下:

2020-04-22T05:18:18.840523Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2020-04-22T05:18:18.840530Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2020-04-22T05:18:18.840537Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-04-22T05:18:18.840544Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-04-22T05:18:18.840548Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-04-22T05:18:18.840552Z 0 [ERROR] Failed to initialize builtin plugins.
2020-04-22T05:18:18.840561Z 0 [ERROR] Aborting

先把自己的mysql设置的低调一点:
innodb_buffer_pool_size = 64M

再加swap,步骤如下:

1) dd if=/dev/zero of=/swapfile bs=1M count=1024
2) mkswap /swapfile
3) swapon /swapfile
4) 添加这行: /swapfile swap swap defaults 0 0 到 /etc/fstab

重启mysqld就好了,试试把。