CentOS 7.1上使用Systemd管理编译安装的MySQL 5.6

WBOY
发布: 2016-06-07 16:07:33
原创
1220 人浏览过

CentOS 7.1默认yum没有MySQL 5.6,稳健的方法是使用MySQL官网提供的源码自行编译安装。但是编译安装的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:

#
# 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=600

Restart=always
PrivateTmp=false

最后应该是这个样子

#
# Simple MySQL systemd service file
#
# systemd supports lots of fancy features, look here (and linked docs) for a full list:

#
# 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=600

Restart=always
PrivateTmp=false

--------------------------------------分割线 --------------------------------------

Ubuntu 14.04下安装MySQL

《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF

Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

Ubuntu 14.04下搭建MySQL主从服务器

Ubuntu 12.04 LTS 构建高可用分布式 MySQL 集群

Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb

MySQL-5.5.38通用二进制安装

--------------------------------------分割线 --------------------------------------

本文永久更新链接地址

来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板