天天看点

Centos7中Mysql5.7.26多实例使用mysqld_multi实现开机启动说明

Centos7中Mysql多实例使用mysqld_multi实现开机启动

  • 说明
    • 编写sh脚本

说明

这里就不讲centos7安装mysql多实例的步骤,下次有空再写一写安装的方法。

编写sh脚本

不多废话,直接上脚本:

vi /etc/rc.d/mysqld_multi_start.sh

文件内容:

#!/bin/bash
export PATH="$PATH":/usr/local/mysql/bin
mysqld_multi start
           

上面的sh脚本写完了,当然了里面的路径就自己根据自己的实际路径调整。

写完了脚本还不行,还要做以下步骤:

  1. 该脚本标记为可执行文件(添加可执行的权限);
chmod +x /etc/rc.d/mysqld_multi_start.sh
  1. 然后将/etc/rc.d/rc.local文件标记为可执行的文件;
chmod +x /etc/rc.d/rc.local
  1. 然后打开/etc/rc.d/rc.local文件,在最后面添加如下脚本;
vi /etc/rc.d/rc.local

文件内容:

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
/etc/rc.d/mysqld_multi_start.sh

           
  1. 重启Centos7;
reboot

这样就实现了Centos7中Mysql5.7.26多实例使用mysqld_multi开机启动!

继续阅读