Created
March 12, 2012 22:35
-
-
Save schmurfy/2025123 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
| # 100Mo | |
| SIZE=$((100 * 1048576 / 512)) | |
| BASEDIR="/usr/local/Cellar/mysql/5.5.15" | |
| BIND_ARGS="--socket=/tmp/mysql_ram.sock" | |
| # create ramdisk | |
| echo "Creating RAMDISK..." | |
| RD_PATH=`hdiutil attach -nomount ram://$SIZE` | |
| # format new volume | |
| echo "Formatting RAMDISK ($RD_PATH)..." | |
| diskutil erasevolume HFS+ "ramdisk" $RD_PATH > /dev/null | |
| cleanup(){ | |
| echo "Destroying RAMDISK ($RD_PATH)..." | |
| hdiutil detach $RD_PATH > /dev/null | |
| } | |
| trap cleanup INT TERM EXIT | |
| # create the database | |
| echo "Creating database..." | |
| /usr/local/bin/mysql_install_db \ | |
| --basedir=$BASEDIR \ | |
| --datadir=/Volumes/ramdisk > /dev/null | |
| trap 'mysqladmin --user=root $BIND_ARGS refresh & wait' 1 # HUP | |
| trap 'mysqladmin --user=root $BIND_ARGS shutdown & wait' 2 3 15 # INT QUIT and TERM | |
| # start the server | |
| echo "Starting server..." | |
| /usr/local/bin/mysqld \ | |
| --no-defaults \ | |
| --basedir=$BASEDIR \ | |
| --datadir=/Volumes/ramdisk \ | |
| --log-error=/Volumes/ramdisk/mysql.ramdisk.err \ | |
| --pid-file=/Volumes/ramdisk/mysql.ramdisk.pid \ | |
| --port=3308 \ | |
| --console \ | |
| $BIND_ARGS & | |
| wait | |
| # Call cleanup manually | |
| trap - INT TERM EXIT | |
| cleanup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment