You are here

MyEnv Installation Guide

This article covers the installation of MyEnv, the MySQL and MariaDB environment of FromDual.

To learn more about what MyEnv is go here.

Table of Contents

MyEnv Requirements

  • Currently MyEnv works on Linux (other UNIXes may work but are not tested).
  • MyEnv works best with recent CentOS or Ubuntu Linux distributions.
  • MyEnv is based on PHP (5.0 to 7.x).
  • A dedicated user (typically mysql) to run the databases is required. This user must have a shell (bash is tested).
  • MyEnv requires the following packages:

CentOS and RHEL


  • php-cli
  • php-mysqli (provided by RPM php-mysql)
  • php-posix (provided by RPM php-process)
  • redhat-lsb-core
  • libaio

shell> sudo yum install php-cli php-mysqli php-posix redhat-lsb-core libaio

Ubuntu and Debian


  • php-cli
  • php-mysql
  • libaio1
  • lsb-release

shell> sudo apt install php-cli php-mysql libaio1 lsb-release



  • php-posix
  • php-pcntl
  • php-mysql
  • php-sockets

shell> sudo zypper install php-posix php-pcntl php-mysql php-sockets

Preparations for MyEnv

In the file /etc/php5/cli/php.ini or /etc/php/7.0/cli/php.ini (Ubuntu) or /etc/php.ini (CentOS), change the setting variables_order to EGPCS.

Then you have to set up the user and the group:

shell> sudo groupadd mysql
shell> sudo useradd -g mysql -d /home/mysql -m -s /bin/bash mysql
shell> sudo passwd mysql

MyEnv runs as user mysql, just like any regular mysqld process.

You might want to check, if the home directory of the user mysql was created at the right place. If not, you can use the following commands to create it:

shell> sudo mkdir -p /home/mysql
shell> sudo chown -R mysql: /home/mysql
shell> sudo mkdir /var/run/mysqld
shell> sudo chown mysql: /var/run/mysqld

Next ist the directory where the MyEnv configuration will be located. DO NOT FORGET to give the mysql user read and write permission for this directory.

shell> sudo mkdir /etc/myenv/
shell> sudo chown -R mysql: /etc/myenv/
shell> sudo chmod 755 /etc/myenv

Switch the user ...

shell> su - mysql

... and create some more folders in his home directory:

shell> mkdir ~/product
shell> mkdir ~/database
shell> mkdir ~/download

  • product is the location of the unpacked binaries. This is the location where MyEnv is looking for them by default.
  • download is intended to be used as landing zone for downloads, such as fresh binary tarballs.
  • database usually contains the datadir of the instances (more precisely instancedir).

Download of MyEnv

MyEnv can be downloaded from the FromDual download page or directly over the command line:

shell> cd ~/download
shell> VERSION='2.0.0'
shell> wget${VERSION}.tar.gz

Once the archive has finished downloading, you can move on to the installation.

Installation of MyEnv

To install MyEnv you have to untar it. It is recommended to do that in the product directory.

shell> cd ~/product
shell> tar xf ~/download/myenv-${VERSION}.tar.gz
shell> ln -s myenv-${VERSION} myenv

Downloading and installing database binary tar-ball

Before you start configuring MyEnv and a MyEnv controlled database instance it is recommended to first install the binary tar ball of your favourite flavour of MySQL/MariaDB:

For MariaDB:


shell> cd ~/download
shell> MAVERSION='10.2.13'
shell> GLIBCVERSION='214'
shell> wget${MAVERSION}/bintar-linux-glibc_${GLIBCVERSION}-x86_64/mariadb-${MAVERSION}-linux-glibc_${GLIBCVERSION}-x86_64.tar.gz
shell> cd ~/product
shell> tar xf ~/download/mariadb-${MAVERSION}-linux-glibc_${GLIBCVERSION}-x86_64.tar.gz
shell> ln -s mariadb-${MAVERSION}-linux-glibc_${GLIBCVERSION}-x86_64 mariadb-${MAVERSION}

For MySQL:


shell> cd ~/download
shell> MYVERSION='5.7.21'
shell> GLIBCVERSION='2.12'
shell> wget${MAVERSION}-linux-glibc${GLIBCVERSION}-x86_64.tar.gz
shell> cd ~/product
shell> tar xf ~/download/mysql-${MYVERSION}-linux-glibc${GLIBCVERSION}-x86_64.tar.gz
shell> ln -s mysql-${MYVERSION}-linux-glibc${GLIBCVERSION}-x86_64 mysql-${MYVERSION}

Configuration of MyEnv

To configure MyEnv you have 2 possibilities:

  • You can configure MyEnv by running the MyEnv installer:
    shell> ~/product/myenv/bin/installMyEnv.php

  • or you can configure MyEnv manually:
    echo 'export MYENV_BASE=/home/mysql/product/myenv' > /etc/myenv/MYENV_BASE
    cp ~/product/myenv/tpl/myenv.conf.template /etc/myenv/myenv.conf
    cp ~/product/myenv/tpl/variables.conf.template /etc/myenv/variables.conf
    cp ~/product/myenv/tpl/aliases.conf.template /etc/myenv/aliases.conf
    cat ~/product/myenv/tpl/profile.template >> ~/.bash_profile

When you have chosen to use the MyEnv installer, follow the steps through the set-up. If you already have binaries available, you get the possibility to create a new database instance.

After each MyENV installation or configuration operation you have to run:

shell> source ~/.bash_profile

Put a database under MyEnv control

Run the MyEnv install script ~/product/myenv/bin/installMyEnv and choose the option "a" (add instance) then follow the instructions.

Or add a section similar to the following example to the MyEnv configuration file /etc/myenv/myenv.conf:

# /etc/myenv/myenv.conf


start                = yes
stop                 = yes
hideschema           = mysql,performance_schema,lost+found,sys
type                 = mysqld
basedir              = /home/mysql/product/mysql-5.7
instancedir          = /home/mysql/database/myenv_test
datadir              = /home/mysql/database/myenv_test/data
user                 = mysql
port                 = 3306
socket               = /var/run/mysqld/mysql-3306.sock
my.cnf               = /home/mysql/database/myenv_test/etc/my.cnf
angel                = no
cgroups              = no
stage                = testing

How MyEnv works

It is always recommended to work as user mysql for starting, stopping and doing maintenance work. Otherwise you run into conflicts with permissions on files, etc.

When you login as user mysql you will get the current status of your environment (if MyEnv is installed and configured correctly):

mysql@master:~ [prodcms, 3308]> u

Up       : mysql-5721 (5.7.21) prodcms (10.2)

Down     : mysql-57 (5.7) mariadb-103 (10.3.8) mysql-4030 (4.0.30)
           mysql-4125 (4.1.25) mariadb-55 (5.5) galera-57-a (5.7)
           galera-57-b (5.7) galera-57-c (5.7)

mysql-5721             (*:3311 ) : cacti
mysql-57               (*:3310 ) : cluster_test test01 test02 test03
mariadb-103            (*:3314 ) : typo3
mysql-4030             (*:3309 ) : test
mysql-4125             (*:3313 ) : test foodmart
mariadb-55             (*:3307 ) : drupal7
prodcms                (*:3308 ) : drupal8
mariadb-55             (*:3312 ) : magento oxid
galera-57-a ( ) : hybris
galera-57-b ( ) : hybris
galera-57-c ( ) : hybris

mysql@master:~ [prodcms, 3308]>


The most important command in MyEnv are:

<instance> : Switches to the environment for this instance. For example:
             shell> mariadb-103
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
             shell> start mysql-805
stop       : Stops the actual instance or a specific instance. For example:
             shell> stop
             shell> stop mariadb-10212
restart    : restarts the actual or a specific instance. For example:
             shell> restart
             shell> restart mysql-5721
bootstrap  : bootstraps a Galera node.
V          : print the current MyEnv version
cdb        : cd to the binlogdir of this instance.
cdd        : cd to the datadir of this instance.
cde        : cd to the etcdir of this instance.
cdh        : cd to the basedir of this instance.
cdi        : cd to the instancedir of this instance.
cdl        : cd to the logdir of this instance.
cdm        : cd to the myenv-directory.
cdt        : cd to the tmpdir of this instance.
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
mv         : mv -i
rm         : rm -i

Some examples:

mysql@chef:~ [mariadb-103, 3318]> u

Up       : mariadb-102 (10.2) mysql-57 (5.7)

Down     : monitoring (5.7) dwh (5.7.21) mariadb-103 (10.3)

monitoring               (*:3319)  : mem mem__advisor_text mem__advisors mem__bean_config mem__config mem__enterprise
                                     mem__events mem__instruments mem__instruments_config mem__inventory mem__quan sys zabbix
mariadb-102              (*:3312 ) : test
dwh                      (*:3325 ) : cms crm datamart download erp focmm foodmart mpm shop staging tellmatic test
mariadb-103              (*:3318 ) : foodmart test world
mysql-57                 (*:3320 ) : FlughafenDB test test2

mysql@chef:~ [mariadb-103, 3318]> dwh
mysql@chef:~ [dwh, 3325]> 

mysql@chef:~ [dwh, 3325]> start
mysql@chef:~ [dwh, 3325]> restart
mysql@chef:~ [dwh, 3325]> stop

mysql@chef:~ [dwh, 3325]> mariadb-102
mysql@chef:~ [mariadb-102, 3312]> cdm
mysql@chef:~/product/myenv [mariadb-102, 3312]> cdh
mysql@chef:~/product/mariadb-10.2 [mariadb-102, 3312]> cdd
mysql@chef:~/database/mariadb-102/data [mariadb-102, 3312]> cdb
mysql@chef:~/database/mariadb-102/binlog [mariadb-102, 3312]> cde
mysql@chef:~/database/mariadb-102/etc [mariadb-102, 3312]> cdl
mysql@chef:~/database/mariadb-102/log [mariadb-102, 3312]> cd 102 103
mysql@chef:~/database/mariadb-103/log [mariadb-102, 3312]> 

MyEnv works with aliases, variables and functions. With the UNIX commands alias, env and declare -F | grep -v '_' you get an overview over the MyEnv functionality.

Upgrade MyEnv

Upgrading MyEnv is very easy. You can proceed as follows if you want to upgrade to a newer version of MyEnv:

shell> su - mysql
shell> cd ~/download
shell> VERSION='2.0.0'
shell> wget${VERSION}.tar.gz
shell> cd ~/product
shell> tar xf ../download/myenv-${VERSION}.tar.gz
shell> unlink myenv
shell> ln -s myenv-${VERSION} myenv

You are basically going to to re-install MyEnv, but with a newer version.

Please also check the Release notes for specific problems.


To enable debugging functionality, use the following command:

shell> export MYENV_DEBUG=1

To disable the debugging again, use the following command:

shell> unset MYENV_DEBUG

Feedback is always welcome! In case you found a bug or you have a feature request, please report it to the FromDual bug tracker or send us an email.

Un-install MyEnv

To un-install MyEnv again just remove the myenv section from your .bash_profile and the ~/product/myenv link:

shell> cd ~/product
shell> sudo rm -rf myenv-x.y myenv /etc/init.d/myenv /etc/myenv

Make sure that the original start/stop script is put back in place and that the my.cnf is at its original location.