Welcome 微信登录

首页 / 数据库 / MySQL / CentOS 7.1上使用Systemd管理编译安装的MySQL 5.6

CentOS 7.1默认yum没有MySQL 5.6,稳健的方法是使用MySQL官网提供的源码自行编译安装。但是编译安装的MySQL 5.6的启动管理是基于CentOS 6.x的service管理方式,不是CentOS 7.x的Systemd的管理方式。MySQL为RHEL和CentOS提供了的MySQL 5.6的yum源,使用yum安装的MySQL是自带Systemd管理脚本文件的。那么,如何用Systemd管理编译安装的MySQL呢?首先看看yum安装的MySQL提供的Systemd管理脚本$ cat /usr/lib/systemd/system/mysqld.service
#
# Simple MySQL systemd service file
#
# systemd supports lots of fancy features, look here (and linked docs) for a full list:
#  http://www.freedesktop.org/software/systemd/man/systemd.exec.html
#
# Note: this file ( /usr/lib/systemd/system/mysql.service )
# will be overwritten on package upgrade, please copy the file to
#
#  /etc/systemd/system/mysql.service

# to make needed changes.
#
# systemd-delta can be used to check differences between the two mysql.service files.
#[Unit]
Description=MySQL Community Server
After=network.target
After=syslog.target[Install]
WantedBy=multi-user.target
Alias=mysql.service[Service]
User=mysql
Group=mysql# Execute pre and post scripts as root
PermissionsStartOnly=true# Needed to create system tables etc.
ExecStartPre=/usr/bin/mysql-systemd-start pre# Start main service
ExecStart=/usr/bin/mysqld_safe# Don"t signal startup success before a ping works
ExecStartPost=/usr/bin/mysql-systemd-start post# Give up if ping don"t get an answer
TimeoutSec=600Restart=always
PrivateTmp=false最后应该是这个样子#
# Simple MySQL systemd service file
#
# systemd supports lots of fancy features, look here (and linked docs) for a full list:
#  http://www.freedesktop.org/software/systemd/man/systemd.exec.html
#
# Note: this file ( /usr/lib/systemd/system/mysql.service )
# will be overwritten on package upgrade, please copy the file to
#
#  /etc/systemd/system/mysql.service

# to make needed changes.
#
# systemd-delta can be used to check differences between the two mysql.service files.
#[Unit]
Description=MySQL Community Server
After=network.target
After=syslog.target[Install]
WantedBy=multi-user.target
Alias=mysql.service[Service]
User=mysql
Group=mysql# Execute pre and post scripts as root
PermissionsStartOnly=true# Needed to create system tables etc.
#ExecStartPre=/usr/bin/mysql-systemd-start pre# Start main service
ExecStart=/usr/local/mysql/bin/mysqld_safe# Don"t signal startup success before a ping works
#ExecStartPost=/usr/bin/mysql-systemd-start post# Give up if ping don"t get an answer
TimeoutSec=600Restart=always
PrivateTmp=false--------------------------------------分割线 --------------------------------------Ubuntu 14.04下安装MySQL http://www.linuxidc.com/Linux/2014-05/102366.htm《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF http://www.linuxidc.com/Linux/2014-03/98821.htmUbuntu 14.04 LTS 安装 LNMP NginxPHP5 (PHP-FPM)MySQL http://www.linuxidc.com/Linux/2014-05/102351.htmUbuntu 14.04下搭建MySQL主从服务器 http://www.linuxidc.com/Linux/2014-05/101599.htmUbuntu 12.04 LTS 构建高可用分布式 MySQL 集群 http://www.linuxidc.com/Linux/2013-11/93019.htmUbuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb http://www.linuxidc.com/Linux/2013-08/89270.htmMySQL-5.5.38通用二进制安装 http://www.linuxidc.com/Linux/2014-07/104509.htm--------------------------------------分割线 --------------------------------------更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14本文永久更新链接地址