Skip to content

Instantly share code, notes, and snippets.

@laurynas
Created October 26, 2012 16:03
Show Gist options
  • Save laurynas/3959636 to your computer and use it in GitHub Desktop.
Save laurynas/3959636 to your computer and use it in GitHub Desktop.
Mysql on ramdrive
description "MD Development Environment"
author "Laurynas Butkus"
#start on startup
#stop on shutdown
stop on runlevel [016]
pre-start script
stop mysql
mkdir -p /mnt/ramdrive
mount -t tmpfs -o size=500M,mode=0777 tmpfs /mnt/ramdrive
mv /var/lib/mysql /var/lib/mysql_real
cp -p -r /var/lib/mysql_md /mnt/ramdrive/mysql
ln -s /mnt/ramdrive/mysql /var/lib/mysql
start mysql
if [ ! -f /tmp/mysql.sock ]; then
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
fi
end script
post-stop script
STOPPED_MYSQL=0
if [ -S /var/run/mysqld/mysqld.sock ]; then
stop mysql
STOPPED_MYSQL=1
fi
rm /var/lib/mysql
mv /var/lib/mysql_real /var/lib/mysql
if [ -d /var/lib/mysql_md_previous ]; then
rm -rf /var/lib/mysql_md_previous
fi
mv /var/lib/mysql_md /var/lib/mysql_md_previous
mv /mnt/ramdrive/mysql /var/lib/mysql_md
umount /mnt/ramdrive
rm /tmp/mysql.sock
if [ $STOPPED_MYSQL -eq 1 ]; then
start mysql
fi
end script
@redross
Copy link

redross commented Oct 26, 2012

Thanks :)

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