Skip to content

Instantly share code, notes, and snippets.

@kurisuchan
Created October 4, 2011 16:43
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save kurisuchan/1262135 to your computer and use it in GitHub Desktop.
Save kurisuchan/1262135 to your computer and use it in GitHub Desktop.
Moving MySQL databases to ramdisk on Ubuntu
# Tweaked from http://tomislavsantek.iz.hr/2011/03/moving-mysql-databases-to-ramdisk-in-ubuntu-linux
# Log in as root
# Mount ramdisk folder in RAM
mkdir /tmp/ramdisk
mount -t tmpfs -o size=128M tmpfs /tmp/ramdisk/
# Move MySQL data
mv /var/lib/mysql /tmp/ramdisk/mysql
ln -s /tmp/ramdisk/mysql/ /var/lib/mysql
# Update permissions
chmod -R 700 /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
restart mysql
@kangasbros
Copy link

Hi, have any idea why this isn't working for me? Basically mysql claims that it can't write/read the files in the directory. Could have some permission type error with ramdisk?

@mauriciosl
Copy link

apparmor will block mysql from read/write other directories, you should configure it at: /etc/apparmor.d/usr.sbin.mysqld

@FinlayDaG33k
Copy link

well thanks, this thing had me reinstall my complete server...

@a2moosh
Copy link

a2moosh commented Aug 20, 2015

congrats, I would recommend a reboot after setting up the database that way ^^ ... not!

@foton
Copy link

foton commented Jan 11, 2017

You can even export just one schema (subfolder)! Apparmor must be modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment