二进制安装后无此文件,加一个

单实例配置

# vim /usr/lib/systemd/system/mysqld.service

[Unit]
Description=MySQL Server
Documentation=man:mysqld(7)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql

Type=forking

PIDFile=/mysql/product/data/mysql.pid

# Disable service start and stop timeout logic of systemd for mysqld service.
TimeoutSec=0

# Start main service
ExecStart=/mysql/app/bin/mysqld --defaults-file=/etc/my.cnf --daemonize --pid-file=/mysql/product/data/mysql.pid $MYSQLD_OPTS

# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/mysql

# Sets open_files_limit
LimitNOFILE = 5000

Restart=on-failure

RestartPreventExitStatus=1

PrivateTmp=false

# chmod 644 mysqld.service

多实例配置

my.cnf文件

# vi /etc/my.cnf
[mysqld@prod1]
...
[mysqld@prod2]
...

mysqld.service文件

同单实例

​mysqld@.service文件

​# vim /usr/lib/systemd/system/mysqld@.service

PIDFile=/mysql/product/data/mysqld-%i.pid
ExecStart=/mysql/app/bin/mysqld --defaults-group-suffix=@%I --daemonize --pid-file=/mysql/product/data/mysqld-%i.pid $MYSQLD_OPTS

mysql.conf文件

# vim /usr/lib/tmpfiles.d/mysql.conf

d /mysql/product/data 0750 mysql mysql  -

# chmod 644 /usr/lib/tmpfiles.d/mysql.conf