You are here
MyEnv (MySQL BasEnv)
What is MyEnv?
MyEnv is a set of scripts to run comfortably multiple MySQL, Percona Server or MariaDB database instances on the same server. You can even run multiple database instances with different binary versions.
MyEnv is more comfortable than mysqld_multi and provides more functionality.
A large MySQL user (Alexa Ranking: Top 500 world-wide, top 20 in Germany) stated: I found MyEnv accidentally when I was searching for something like this. I liked it immediately more than MySQL Sandbox or
mysqld_multi. A very comfortable tool. Thank you very much!
When to use MyEnv?
MyEnv is useful when you have to install several MySQL database instances on one machine. This has to be done typically:
- when you have to consolidate many databases from dedicated servers into fewer machines or
- when you have to separate the data of different customers into different databases if you provide Software-as-a-Service (SaaS) solutions (for example hoster or internal IT departments for big companies).
MyEnv has the advantage over virtualization solutions (like VMWare or VirtualBox) that you do not have the overhead of an additional virtual machine and the installed operating system.
- Currently those scripts work on UNIX only (only Linux is tested).
- PHP must be installed (
- A user where the MySQL database runs with (typically
mysql) must exist.
More sources for MyEnv
MyEnv can be downloaded here.
For questions, feedback and comments, please go to our MyEnv forum.
Bug and feature request can be reported here.
How to install MyEnv
Ideally you install the tar-ball in the home directory of your mysql user (typically
shell> su - mysql shell> cd /download shell> wget http://www.shinguz.ch/download/myenv-latest.tar.gz shell> mkdir ~/product shell> cd ~/product shell> tar xf /download/myenv-latest.tar.gz shell> ln -s myenv-x.y myenv
Upgrading MyEnv is very simple. You can proceed as follows:
shell> su - mysql shell> cd /download shell> wget http://www.shinguz.ch/download/myenv-0.5.tar.gz shell> cd ~/product shell> tar xf /download/myenv-0.5.tar.gz shell> cp myenv/etc/myenv.conf myenv-0.5/etc/ shell> rm myenv shell> rm: remove symbolic link `myenv'? y shell> ln -s myenv-0.5 myenv
You have 2 possibilities:
- You can configure MyEnv by running the
- Or you can configure MyEnv manually:
shell> cp myenv/etc/myenv.conf.template myenv/etc/myenv.conf shell> cat myenv/profile.template >> .bash_profile
Then logout and login again...
If you want to have your databases stopped and started automatically copy
/etc/init.d and link it correctly to the different run levels.
On Debian and Ubuntu:
# sudo update-rc.d myenv defaults
On Red Hat, Fedore and CentOS:
To de-install MyEnv again just remove the myenv section from your
.bash_profile and the
shell> cd ~/product shell> rm -rf myenv-x.y myenv /etc/init.d/myenv
Make sure that the original start/stop script is put back in place and that the
my.cnf is at its original location.
Put a database under MyEnv control
Add a section similar to the following example to
# # myenv/etc/myenv.conf # [test] basedir = /usr/local/mysql datadir = /var/lib/mysql port = 3306 socket = /tmp/mysql-3306.sock my.cnf = /etc/my.cnf start = YES stop = YES
How MyEnv works
You should always work as user
mysql for starting, stopping and doing maintenance work.
When you login you get the following display:
Up : mysqld523 (5.2.3) Down : mysqld5115 (5.1.16) mysqld5037 (5.0.37) mysqld4027 (4.0.27) mysqld4122 (4.1.22) mysqld523 (3323) : cacti mysql test mysqld5116 (3325) : cluster_test mysql test mysqld5037 (3307) : mysql test mysqld4027 (3320) : mysql test mysqld4122 (3319) : mysql test FoodMart mysql@master:~ [mysqld523, 3323]>
The most important commands are:
<instance> : Switches to the environment for this instance. For example: shell> mysqld5116 u or up : Lists, which releases are available, which instances are up and down and which instance contains which database. For example: shell> u start : Starts the actual or a specific instance. For example: shell> start or shell> start mysqld5116 stop : Stops the actual instance or a specific instance. For example: shell> stop or shell> stop mysqld5116 restart : restarts the actual or a specific instance. For example: shell> restart or shell> restart mysqld5116 cdh, cdb : cd to the basedir of this instance. cdd : cd to the datadir of this instance. cdc : cd to the cluster-directory of this instance. cde : cd to the myenv-directory. cd a b : cd to a directory with the name where a is substituted by b. For example: shell> pwd /var/lib/mysql1 shell> cd 1 2 shell> pwd /var/lib/mysql2 ll : ls -l la : ls -la
To enable debugging functionality use:
shell> export MYENV_DEBUG=1
To disable debugging functionality again use:
shell> unset MYENV_DEBUG
Actual and past releases you can find here for download.