I have a second MySQL 8 instance running on Ubunut 20.04, started by this command:

mysqld_safe --defaults-file=/home/user/mysqld_replica.cnf &

The config file contains all needed settings like port, socket and data dir. That works well but I can not figure out how to start the second instance on boot.

What would be the recommended way to start both instances at boot time?

1 Answer 1


Copy /lib/systemd/system/mysql.service to /etc/systemd/system/mysql_replica.service.

In the copied service file add --defaults-file=/home/user/mysqld_replica.cnf to the ExecStart* directives as the first argument to mysqld.

Reload systemd to read this systemctl daemon-reload.

Start the service systemctl start mysql_replica.service.

Enable on boot with systemctl enable mysql_replica.service.

You many need a few quick apparmor fixes like this answer to enable writing on your second data directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.