content_image/798067.jpg content_image/798068.jpg content_image/798074.jpg
Instances then are managed by normal systemd commands, such as: 

systemctl start mysqld@replica01 systemctl start mysqld@replica02 

To enable instances to run at boot time, do this: 

systemctl enable mysqld@replica01 systemctl enable mysqld@replica02 

Use of wildcards is also supported. For example, this command displays the status of all replica instances: 

systemctl status ’mysqld@replica*’ 

For management of multiple MySQL instances on the same machine, systemd automatically uses a different unit file: 

• mysqld@.service  rather than mysqld.service  (RPM platforms) 

• mysql@.service  rather than mysql.service  (Debian platforms) 

In the unit file, %I  and %i  reference the parameter passed in after the @  marker and are used to manage the specific instance. For a command such as this: 

systemctl start mysqld@replica01 

systemd starts the server using a command such as this: 

mysqld --defaults-group-suffix=@%I ... 

The result is that the [server] , [mysqld] , and [mysqld@replica01]  option groups are read and used for that instance of the service. 

## Migrating from mysqld_safe to systemd 

<img src='content_image/798067.jpg'>

<img src='content_image/798068.jpg'>

## Note 

On Debian platforms, AppArmor prevents the server from reading or writing / var/lib/mysql-replica* , or anything other than the default locations. To address this, you must customize or disable the profile in /etc/apparmor.d/ usr.sbin.mysqld . 

## Note 

On Debian platforms, the packaging scripts for MySQL uninstallation cannot currently handle mysqld@  instances. Before removing or upgrading the package, you must stop any extra instances manually first. 

Because mysqld_safe  is not installed on platforms that use systemd to manage MySQL, options previously specified for that program (for example, in an [mysqld_safe]  or [safe_mysqld]  option group) must be specified another way: 

•Some mysqld_safe  options are also understood by mysqld  and can be moved from the [mysqld_safe]  or [safe_mysqld]  option group to the [mysqld]  group. This does not  include -- pid-file , --open-files-limit , or --nice . To specify those options, use the override.conf systemd file, described previously. 

<img src='content_image/798074.jpg'>

## Note 

On systemd platforms, use of [mysqld_safe]  and [safe_mysqld]  option groups is not supported and may lead to unexpected behavior. 

