Created
July 10, 2012 20:26
-
-
Save jaysonsantos/3086030 to your computer and use it in GitHub Desktop.
MySQL in ram with ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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