I need to have multiple instances of MySQL running on my PC. I did this:

yum install mariadb-server mariadb => install mysql

mysql_install_db --datadir=/var/lib/mysql => use mysql_install_db to create datadir for the first instance

mysql_install_db --datadir=/var/lib/mysql2=> use mysql_install_db to create datadir for the second instance

chown -R mysql:mysql /var/lib/mysql chown owner-user:owner-group

chown -R mysql:mysql /var/lib/mysql2 chown owner-user:owner-group

Then I modified my.cnf file for multiple instances:

#password       = your_password
port            = 3306
socket          = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs

# The MariaDB server
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin

port            = 3306
socket          = /var/lib/mysql/mysql.sock
pid-file        = /var/run/mysqld/mysqld.pid
datadir         = /var/lib/mysql
server-id = 1
log-bin = mysql-bin
binlog_format = mixed

port            = 3307
socket          = /var/lib/mysql2/mysql.sock
pid-file        = /var/run/mysqld/mysqld2.pid
datadir         = /var/lib/mysql2
server_id       = 2

Then I used this command mysqld_multi report and got this:

Reporting MySQL servers
MySQL server from group: mysqld0 is not running
MySQL server from group: mysqld2 is not running

Then I used mysqld_multi start and mysqld_multi report and got the same message again:

Reporting MySQL servers
MySQL server from group: mysqld0 is not running
MySQL server from group: mysqld2 is not running

I was surfing over the Internet and found out this solutions multiple instances and mysqld_multi. But I did not find any key to my problem. What am I going to do to run my instances?

  • Standard question: is SELinux on? (Run getenforce.) Jan 19, 2016 at 12:55
  • When I ran getenforce I got Enforcing.
    – fuser
    Jan 19, 2016 at 15:25
  • Try to disable the selinuxand then restart the host. Disabling selinux need reboot
    – AReddy
    Jan 19, 2016 at 17:16
  • @AngRed: setenforce 0 should do it, but you're right insofar as the persistent config is in /etc/sysconfig/selinux. Jan 19, 2016 at 19:05
  • Regrettably, it did not give a proper effect. Nothing changed.
    – fuser
    Jan 20, 2016 at 6:49

2 Answers 2


I found out why I couldn't start my two instances. It was necessary to comment [client] section in /etc/my.cnf file and wrote unit for /etc/systemd/system in a proper way. Here is the way I did it:

Configuration of /etc/my.cnf file:

mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin

user    = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock

user = mysql
pid-file = /var/run/mysqld/mysqld2.pid
socket = /var/run/mysqld/mysqld2.sock

max_allowed_packet = 16M

# Remove the next comment character if you are not familiar with SQL

key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M


Configuration of /etc/systemd/system/mysqld_multi_service.service:

Description= mysqld_multi_service

ExecStart=/usr/bin/mysqld_multi start
ExecStop=/usr/bin/mysqld_multi stop


Then systemctl enable mysqld_multi_service.service and systemctl start mysqld_multi_service.service. After ALL this steps you can connect to the first instance using this command:

mysql -u root -S /var/run/mysqld/mysqld.sock

or to the second instance:

mysql -u root -S /var/run/mysqld/mysqld2.sock


From the MySQL documentation, it looks like mysql_multi should not be used anymore:

Because systemd has the capability of managing multiple MySQL instances on platforms for which systemd support is installed, mysqld_multi and mysqld_multi.server are unnecessary and are not installed. This is true as of MySQL 5.7.13 for RPM platforms, 5.7.19 for Debian platforms.

Instead, you should use systemd to manage the instances that you setup in the my.cnf configuration file. See the section Configuring Multiple MySQL Instances Using systemd in the link provided.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .