Ever quickly needed a fresh MySQL server to run some tests?
Always envied PostgreSQL for the cool pg_virtualenv?
Now you can have a piece of the cake too!
git clone https://github.com/evgeni/my_virtualenv.git
There is no fancy shell script you can curl ... | sh (well, actually... nononono, forget it!).
- a POSIX compatible shell
- MySQL (tested with 8.0) or MariaDB (tested with 10.6), other versions and flavors should work but are untested
- either
pwgenor an MD5 command line tool (eithermd5sumfrom GNU coreutils ormd5from OSX or OpenSSL) - either
ss(from iproute2) ornc(from any netcat implementation)
Well, there is none, really.
Either just call my_virtualenv and get a fresh shell with a mysqld running in the background:
$ my_virtualenv
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.33-1 (Debian)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Or wrap your tests with it:
$ my_virtualenv make test
echo "CREATE DATABASE test;" | mysql
run-your-cool-mysql-depending-tests
After the command/shell terminates, the running mysqld gets killed and all the data is removed.
When running my_virtualenv, your environment gets poluted with the following (useful) vars:
MYSQL_USER- the user you can connect asMYSQL_PWD- the password of your userMYSQL_HOME- the place to findmy.cnfMYSQL_HOST- the hostmysqldis running on (alwayslocalhost)MYSQL_TCP_PORT- the TCP port ofmysqldMYSQL_UNIX_PORT- the path to themysqldsocket