Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Script to start a second mysql server using ramdisk/tmpfs for unit tests.
pkill -9 -f mysql.*datadir.*$DATADIR
mkdir -p $DATADIR
mkdir -p $TMPDIR
chown -R mysql.mysql $DATADIR
chown -R mysql.mysql $TMPDIR
rm -f $DATADIR/ib*
echo "=== Installing MySQL DB ==="
mysql_install_db --user=mysql --datadir=$DATADIR
# Note: this only overrides stuff in /etc/my.cnf. Other settings are taken from
# there and are quite important!
echo "=== Starting IN-MEMORY MYSQL SERVER ==="
/usr/sbin/mysqld --port=3307 \
--datadir=$DATADIR \
--innodb_data_home_dir=$DATADIR \
--innodb_log_group_home_dir=$DATADIR \
--tmpdir=$TMPDIR \
--socket=$MYSQL_SOCKET \
--log-error=/dev/shm/mysql.err &
echo "=== Waiting ==="
sleep 10
echo "=== Setting root password ==="
export MYSQL_PASSWORD=bunnies
mysql --socket=$MYSQL_SOCKET -u root -e "SET PASSWORD = PASSWORD('bunnies')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment