添加交换分区:
sudo dd if=/dev/zero of=/swapfile bs=56M count=16
sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile && sudo swapon -s
/etc/fstab内追加:
/swapfile swap swap defaults 0 0
增加/etc/mysql/mysql.conf.d/mysqld.cnf内[mysqld]下的参数配置:
innodb_buffer_pool_size=16M(至关重要!)
然后重启mysql服务:
sudo systemctl restart mysql.service
512M RAM主机内存优化方法