Skip to content

Instantly share code, notes, and snippets.

@jaysonsantos
Created July 10, 2012 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaysonsantos/3086030 to your computer and use it in GitHub Desktop.
Save jaysonsantos/3086030 to your computer and use it in GitHub Desktop.
MySQL in ram with ubuntu
#!/bin/bash
function quit {
echo "Umounting temp"
cd /
umount /media/tmp
}
trap quit SIGINT
if [ "$(whoami)" != "root" ]
then
sudo "$(readlink -f "$0")"
exit 0
fi
if [ ! -d /media/tmp ]
then
mkdir /media/tmp
fi
mount -t tmpfs tmpfs /media/tmp -rw
chmod 777 -R /media/tmp/
rsync -av /var/lib/mysql/ /media/tmp/
if [ -f /var/run/mysqld/mysqld.pid ]; then
kill $(cat /var/run/mysqld/mysqld.pid)
rm /var/run/mysqld/mysqld.pid
fi
cd /media/tmp
mysqld -h/media/tmp/
quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment