You can find this document as PDF here.

1. About

MyEnv is a tool to run several MySQL, MariaDB or PostgreSQL database instances on ONE host without using any virtualization or container technologies. You can even run multiple database instances with different versions on the same machine. We call this multi-instance set-ups.

With MyEnv a multi-instance set-up is more comfortable to handle than with mysqld_multi (old) or Systemd services (new) and it provides more useful functionality.

Using MyEnv does not need the use of the root user to operate a database instances. Thus it is appropriate for classical enterprise DBA organizations.

Further multi-instance set-ups is a much more efficient way of consolidating MySQL and MariaDB instances an has less overhead than virtualization solutions. To do proper resource fencing MyEnv provides cgroup integration (container integration (docker/incus/lxd) is planned in the future).

2. Installation Guide

2.1. Prerequisites

  • Currently MyEnv works on Linux (other UNIXes may work but are not tested).

  • MyEnv works best with recent Debian, Ubuntu or Rocky Linux Linux distributions.

  • MyEnv is based on PHP.

  • A dedicated user (typically dba) to run the databases is required. This user must have a shell (bash is tested).

2.2. Download and Install MyEnv

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

$ cd /tmp
$ VERSION='2.1.1'
$ wget https://support.fromdual.com/admin/download/myenv-${VERSION}.tar.gz

2.3. Adding FromDual DEB or RPM repositories

…​

2.4. Installation of MyEnv from FromDual Repository on Debian / Ubuntu

Debian
Ubuntu

MyEnv requires the following packages:

  • php-cli

  • php-mysql

  • libaio1

  • lsb-release

Install the packages as follows: $ sudo apt install php-cli php-mysql libaio1 lsb-release

2.5. Installation of MyEnv from FromDual Repository on Rocky Linux / Red Hat Linux / Oracle Linux / AlmaLinux / Fedora / CentOS

Rocky Linux
Red Hat
Oracle Linux
AlmaLinux
Fedora
CentOS

MyEnv requires the following packages:

  • php-cli

  • php-mysqli (provided by RPM php-mysql)

  • php-posix (provided by RPM php-process)

  • libaio

Install the packages as follows:

$ sudo dnf install php-cli php-mysqli php-posix libaio

2.6. Installation of MyEnv on OpenSUSE and SLES

suse

MyEnv requires the following packages:

  • php-posix

  • php-pcntl

  • php-mysql

  • php-sockets

Install the packages as follows:

$ sudo zypper install php-posix php-pcntl php-mysql php-sockets

2.7. Installation of FromDual MyEnv from a binary tarball

2.7.1. 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.

MyEnv is assumed to run under the user dba. Thus you have to create this user and its group:

$ sudo groupadd --system dba
$ sudo useradd --system --gid dba --home-dir /home/dba --create-home --shell /bin/bash dba
$ sudo passwd dba

Some directories for database socket files are needed as well:

$ sudo mkdir /run/mysqld /run/mariadb
$ sudo chown dba: /run/mysqld /run/mariadb

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

$ sudo mkdir /etc/myenv
$ sudo chown -R dba: /etc/myenv
$ sudo chmod 740 /etc/myenv

Switch the user:

$ su - dba

and create some more folders in his home directory:

$ mkdir ~/product ~/database ~/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).

2.7.2. Installation of MyEnv

To install MyEnv you have to untar it. It is assumed to do that in the product directory of the dba user.

$ VERSION='2.1.1'
$ cd ~/product
$ tar xf /tmp/myenv-${VERSION}.tar.gz
$ ln -s myenv-${VERSION} myenv

2.8. Testing FromDual MyEnv installation

$ ~/product/myenv/bin/showMyEnvVersion.php

3. User Guide

3.1. Technical Overview

…​

3.2. Downloading and installing database binary tarball

Before you start configuring MyEnv and a MyEnv controlled database instance it is recommended to first install the binary tarball of your favourite database MariaDB, MySQL or PostgreSQL:

3.3. For MariaDB

mariadb

Go to the MariaDB Downloads page, choose MariaDB Server VersionLinuxArchitectureInit System to choose the release you want to use. And download the tarball to the ~/download directory. Alternatively you can do it also on the command line:

$ su - dba
$ cd ~/download
$ MAVERSION='12.3.2'
$ wget https://archive.mariadb.org//mariadb-${MAVERSION}/bintar-linux-systemd-x86_64/mariadb-${MAVERSION}-linux-systemd-x86_64.tar.gz
$ cd ~/product
$ tar xf ~/download/mariadb-${MAVERSION}-linux-systemd-x86_64.tar.gz
$ ln -s mariadb-${MAVERSION}-linux-systemd-x86_64 mariadb-${MAVERSION}

3.4. For MySQL

mysql

Go to the Download MySQL Community Server page and choose Select VersionLinux - GenericOS Version to choose the release you want to use. And download the tarball to the ~/download directory. Alternatively you can do it also on the command line:

$ sudo apt install xz-utils   # On Debian
$ su - dba
$ cd ~/download
$ MYVERSION='9.7.3'
$ MAJOR=$(echo ${MYVERSION} | cut -d. -f-2)
$ GLIBCVERSION='2.28'
$ wget https://dev.mysql.com/get/Downloads/MySQL-${MAJOR}/mysql-${MYVERSION}-linux-glibc${GLIBCVERSION}-x86_64.tar.xz
$ cd ~/product
$ tar xf ~/download/mysql-${MYVERSION}-linux-glibc${GLIBCVERSION}-x86_64.tar.xz
$ ln -s mysql-${MYVERSION}-linux-glibc${GLIBCVERSION}-x86_64 mysql-${MYVERSION}

3.5. For PostgreSQL

postgresql

For PostgreSQL we did not find binary tarballs. So we have to create them ourselfs:

3.5.1. Compile PostgreSQL from Source

$ cd postgresql
$ ./configure
$ make -j 4
$ su
$ make install
$ adduser postgres
$ mkdir -p /usr/local/pgsql/data
$ chown postgres /usr/local/pgsql/data
$ su - postgres
$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
$ /usr/local/pgsql/bin/createdb test
$ /usr/local/pgsql/bin/psql test

3.5.2. Create a PostgreSQL binary tarball (.tar.gz)

$ cd postgresql
$ ./configure --prefix=/tmp/postgresql-19.dev-x86_64
$ make -j 4
$ make install
$ tar -C /tmp -czf /tmp/postgresql-19.dev-x86_64.tar.gz postgresql-19.dev-x86_64
$ cp /tmp/postgresql-19.dev-x86_64.tar.gz /download

3.5.3. Install a PostgreSQL binary tarball (.tar.gz) under MyEnv

$ su - dba
$ cd product
$ tar xf ~/download/postgresql-19.dev-x86_64.tar.gz
$ ln -s postgresql-19.dev-x86_64 postgresql-19

3.6. Configuration of MyEnv

To configure MyEnv you have 2 possibilities:

  • You can configure MyEnv by running the MyEnv installer:

    $ ~/product/myenv/bin/installMyEnv.php
  • or you can configure MyEnv manually:

    $ sudo echo 'export MYENV_BASE=/home/dba/product/myenv' > /etc/myenv/MYENV_BASE
    $ sudo cp /home/dba/product/myenv/tpl/myenv.conf.template /etc/myenv/myenv.conf
    $ sudo cp /home/dba/product/myenv/tpl/variables.conf.template /etc/myenv/variables.conf
    $ sudo cp /home/dba/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:

$ source ~/.bash_profile

3.7. Put MyEnv under Systemd controll

    $ sudo cp /home/dba/product/myenv/tpl/systemd.myenv.dba.unit.template /etc/systemd/system/myenv.service
    $ sudo systemctl daemon-reload
    $ sudo systemctl enable myenv.service
    Created symlink /etc/systemd/system/myenv → /etc/systemd/system/myenv.service.

    $ sudo systemctl status myenv.service
    ● myenv.service - FromDual Environment for MySQL and MariaDB (myenv)
       Loaded: loaded (/etc/systemd/system/myenv.service; enabled; vendor preset: enabled)
       Active: inactive (dead)
         Docs: https://www.fromdual.com/myenv-installation-guide

    $ sudo systemctl start myenv
    $ sudo systemctl status myenv
    ● myenv.service - FromDual Environment for MySQL and MariaDB (myenv)
       Loaded: loaded (/etc/systemd/system/myenv.service; enabled; vendor preset: enabled)
       Active: active (running) since Tue 2020-09-01 09:42:39 CEST; 4s ago
         Docs: https://www.fromdual.com/myenv-installation-guide
      Process: 19532 ExecStartPre=/bin/mkdir -p /var/run/myenv /var/run/mysqld (code=exited, status=0/SUCCESS)
      Process: 19533 ExecStartPre=/bin/chown mysql: /var/run/myenv /var/run/mysqld (code=exited, status=0/SUCCESS)
     Main PID: 19534 (myenv_start_sto)
        Tasks: 32 (limit: 4915)
       Memory: 343.7M
       CGroup: /system.slice/myenv.service
               ├─19534 /usr/bin/php -d variables_order=EGPCS /home/mysql/product/myenv/bin/myenv_start_stop.php start
               ├─19552 bin/mysqld --defaults-file=/home/mysql/database/monitoring/etc/my.cnf --basedir=/home/mysql/product/mysql-5.7 --datadir=/home/mysql/database/monitoring/data --user=mysql
               ├─19584 sh -c export LC_ALL=C ; /usr/bin/php -d variables_order=EGPCS -f /home/mysql/product/myenv-2.0.2/bin/database.php mysql-80 start 2>&1 2>/tmp/my_exec.stderr.19534
               ├─19585 /usr/bin/php -d variables_order=EGPCS -f /home/mysql/product/myenv-2.0.2/bin/database.php mysql-80 start
               └─19595 bin/mysqld --defaults-file=/home/mysql/database/mysql-80/etc/my.cnf --basedir=/home/mysql/product/mysql-8.0 --datadir=/home/mysql/database/mysql-80/data --user=mysql

    Sep 01 09:42:39 boss systemd[1]: Starting FromDual Environment for MySQL and MariaDB (myenv)...
    Sep 01 09:42:39 boss systemd[1]: Started FromDual Environment for MySQL and MariaDB (myenv).

    $ tail -f /home/dba/product/myenv/log/myenv_start_stop.log -n 1000
    2025-09-01 09:42:39 Starting myenv_start_stop
    2025-09-01 09:42:39 Starting instances: monitoring mysql-80 dwh mysql-84 mariadb-114 mariadb-118 mysql-8019
    2025-09-01 09:42:39   Starting instance: monitoring
    2025-09-01 09:42:42   Starting instance: mysql-80
    2025-09-01 09:42:54   Starting instance: dwh
    2025-09-01 09:42:57   Starting instance: mysql-84
    2025-09-01 09:43:00   Starting instance: mariadb-114
    2025-09-01 09:43:03   Starting instance: mariadb-118
    2025-09-01 09:43:10   Starting instance: mysql-8019
    2025-09-01 09:43:18 Finished myenv_start_stop (rc=0).

3.7.1. Configuartion of PostgreSQL

{%collapsible%}

[pg18]

start                = yes
stop                 = yes
type                 = mysqld
basedir              = /home/mysql/product/postgresql-18
instancedir          = /home/mysql/database/pg18
datadir              = /home/mysql/database/pg18/data
user                 = mysql
port                 = 5433
socket               = /run/postgresql/.s.PGSQL.5433
my.cnf               = /home/mysql/database/pg18/etc/postgresql.conf
angel                = no
cgroups              = no
stage                = testing

3.8. 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
#
[test]
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               = /run/mysqld/mysql-3306.sock
my.cnf               = /home/mysql/database/myenv_test/etc/my.cnf
angel                = no
cgroups              = no
stage                = testing

3.9. 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):

dba@master:~ [prodcms, 3308]> u
Up       : mysql-8421 (5.7.21) prodcms (10.2)
Down     : mysql-84 (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-8421             (*:3311 ) : cacti
mysql-84               (*:3310 ) : cluster_test test01 test02 test03
                                   test04
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 (192.168.57.1:3306 ) : hybris
galera-57-b (192.168.57.2:3306 ) : hybris
galera-57-c (192.168.57.3:3306 ) : hybris
dba@master:~ [prodcms, 3308]>

3.10. Functionality

The most important command in MyEnv are:

<instance> : Switches to the environment for this instance. For example:
             $ mariadb-103
u or up    : Lists, which releases are available, which instances are up and
             down and which instance contains which database. For example:
             $ u
start      : Starts the actual or a specific instance. For example:
             $ start
             or
             $ start mysql-805
stop       : Stops the actual instance or a specific instance. For example:
             $ stop
             or
             $ stop mariadb-10212
restart    : restarts the actual or a specific instance. For example:
             $ restart
             or
             $ restart mysql-8421
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:
             $ pwd /var/lib/mysql1
             $ cd 1 2
             $ pwd /var/lib/mysql2
ll         : ls -l
la         : ls -la
mv         : mv -i
rm         : rm -i

Some examples:

dba@chef:~ [mariadb-103, 3318]> u
Up       : mariadb-102 (10.2) mysql-84 (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-84                 (*:3320 ) : FlughafenDB test test2
dba@chef:~ [mariadb-103, 3318]> dwh
dba@chef:~ [dwh, 3325]>
dba@chef:~ [dwh, 3325]> start
. SUCCESS!
dba@chef:~ [dwh, 3325]> restart
.. SUCCESS!
. SUCCESS!
dba@chef:~ [dwh, 3325]> stop
.. SUCCESS!
dba@chef:~ [dwh, 3325]> mariadb-102
dba@chef:~ [mariadb-102, 3312]> cdm
dba@chef:~/product/myenv [mariadb-102, 3312]> cdh
dba@chef:~/product/mariadb-10.2 [mariadb-102, 3312]> cdd
dba@chef:~/database/mariadb-102/data [mariadb-102, 3312]> cdb
dba@chef:~/database/mariadb-102/binlog [mariadb-102, 3312]> cde
dba@chef:~/database/mariadb-102/etc [mariadb-102, 3312]> cdl
dba@chef:~/database/mariadb-102/log [mariadb-102, 3312]> cd 102 103
dba@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.

3.11. Upgrading MyEnv

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

$ su - mysql
$ cd ~/download
$ VERSION='2.1.1'
$ wget https://support.fromdual.com/admin/download/myenv-${VERSION}.tar.gz
$ cd ~/product
$ tar xf ../download/myenv-${VERSION}.tar.gz
$ unlink myenv
$ 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.

3.12. Un-install MyEnv

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

$ cd ~/product
$ 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.

3.13. Troubleshooting

To enable debugging functionality, use the following command:

$ export MYENV_DEBUG=1

To disable the debugging again, use the following command:

$ 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](https://support.fromdual.com/bugs "FromDual bug tracker") or send us an email.

4. Enterprise Subscription and Support

…​

5. Release Notes

6. Questions and Answers (Q & A)

Question: How can I set a default instance chosen when I log in?

Answer: In the configuration file /etc/myenv/myenv.conf you can add a default instance in the [default] section as follows:

    #
    # /etc/myenv/myenv.conf
    #

    [default]

    default              = mariadb-123

This instance leads to the following prompt and environment when logged in:

dba@boss:~ [mariadb-123, 3306]>

Question: We were unable to stop an instance through myenv but start is working fine. How can we find the problem?

    [root@ip-172-31-46-213 ~]# su - mysql

    Up       : Master (5.7.30) Slave (5.7.30)

    Down     :

    Master (*:3306 ) :
    Slave  (*:3307 ) :

    dba@ip-172-31-46-213:~ [Master, 3306]> stop
    ERROR: Cannot find nor guess PID file (rc=520). Is it possible that the database is already
    stopped? (rc=520)
    ERROR: Stopping instance Master failed (rc=546).

Answer: In all FromDual tools the return code (rc)is unique. So you can easily find where in the code the error happened. In your case it is in lib/MyEnv.inc in the function stopInstance.

In the code we check if PID file is empty. And it is empty if it cannot be found:

  • in my.cnf specified in myenv.conf as variable pid_file or pid-file

  • under $datadir/mysqld.pid

  • under $datadir/<hostname>.pid

It would be interesting for us if you could tell us where your PID file is located and where it is configured (SHOW GLOBAL VARIABLES LIKE 'pid%';).