Skip to content

Instantly share code, notes, and snippets.

@dinks
Forked from nghuuphuoc/Add swap
Last active September 1, 2015 14:45
Show Gist options
  • Save dinks/a2b4acbdc738f28ed010 to your computer and use it in GitHub Desktop.
Save dinks/a2b4acbdc738f28ed010 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