Skip to content

Instantly share code, notes, and snippets.

@nghuuphuoc
Last active December 7, 2020 10:55
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nghuuphuoc/8034113 to your computer and use it in GitHub Desktop.
Save nghuuphuoc/8034113 to your computer and use it in GitHub Desktop.
Fix MySQL issue "Fatal error: cannot allocate memory for the buffer pool" on Digital Ocean server
// Check swap
$ sudo swapon -s
Filename Type Size Used Priority --> empty
// Create and enable swap file
$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
$ sudo mkswap /swapfile
Setting up swapspace version 1, size = 262140 KiB
no label, UUID=103c4545-5fc5-47f3-a8b3-dfbdb64fd7eb
// Activate swap
$ sudo swapon /swapfile
// View swap summary
$ swapon -s
Filename Type Size Used Priority
/swapfile file 262140 0 -1
$ echo 0 | sudo tee /proc/sys/vm/swappiness
// Set swap file permission
$ sudo chown root:root /swapfile
$ sudo chmod 0600 /swapfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment