centos7下创建mysql5.6多实例

centos7下创建mysql5.6多实例,第1张

概述一、mysql安装目录说明mysql5.6以二进制安装包安装在/data/mysql56下数据目录为/data/mysql56/data下配置文件为/etc/my.cnf下二、多实例目录说明/mysq

一、MysqL安装目录说明
MysqL5.6以二进制安装包安装在/data/MysqL56下
数据目录为/data/MysqL56/data下
配置文件为/etc/my.cnf下

二、多实例目录说明
/MysqL-instance
         |-- 3308
                  |-- data  #3308实例数据目录
         |-- 3309
                  |-- data  #3309实例数据目录

> mkdir -p /MysqL-instance/3308/data> mkdir -p /MysqL-instance/3309/data

                 
三、复制配置文件到实例目录下

> cp /data/MysqL56/support-files/my-default.cnf /MysqL-instance/3308/my.cnf> cp /data/MysqL56/support-files/my-default.cnf /MysqL-instance/3309/my.cnf


四、修改配置文件

> vi /MysqL-instance/3308/my.cnf> vi /MysqL-instance/3309/my.cnf
[clIEnt]port = 3308socket = /MysqL-instance/3308/MysqL.sock[MysqL]no-auto-rehash[MysqLd]user = MysqLport = 3308socket = /MysqL-instance/3308/MysqL.sockbasedir = /data/MysqL56datadir = /MysqL-instance/3308/datapID-file = /MysqL-instance/3308/MysqL.pIDrelay-log = /MysqL-instance/3308/relay-binrelay-log-info-file = /MysqL-instance/3308/relay-log.infoserver-ID = 12[MysqLd_safe]log-error = /MysqL-instance/3308/MysqL.errpID-file = /MysqL-instance/3308/MysqL.pID

3309的配置同上,只需把3308的地方换成3309

五、创建MysqL多实例启动文件

> vi /MysqL-instance/3308/MysqL> vi /MysqL-instance/3309/MysqL
#!/bin/shport=3308MysqL_user="root"#请填写自已数据库密码MysqL_pwd="123456"cmd_path="/data/MysqL56/bin"MysqL_sock="/MysqL-instance/${port}/MysqL.sock"MysqL_start() {    if [ ! -e "$MysqL_sock" ];then        printf "MysqL start ... \n"        /bin/sh ${cmd_path}/MysqLd_safe --defaults-file=/MysqL-instance/${port}/my.cnf 2>&1 > /dev/null &    else        printf "MysqL is running ... \n"        exit    fi}MysqL_stop() {    if [ ! -e "$MysqL_sock" ];then        printf "MysqL is stopped ... \n"        exit    else        printf "MysqL stop ... \n"        ${cmd_path}/MysqLadmin -u ${MysqL_user} -p${MysqL_pwd} -S /MysqL-instance/${port}/MysqL.sock shutdown    fi}MysqL_restart() {    printf "MysqL restart ... \n"    MysqL_stop    sleep 2    MysqL_start}case  in    start) MysqL_start ;;    stop) MysqL_stop ;;    restart) MysqL_restart ;;*)printf "usage: /data/${port}/MysqL {start|stop|restart}\n"esac

 
六、授权MysqL用户目录权限

> chown -R MysqL.MysqL /MysqL-instance> chmod 700 /MysqL-instance/3308/MysqL> chmod 700 /MysqL-instance/3309/MysqL

 
七、初始化MysqL多实例数据库文件

> cd /daa/MysqL56/scripts> ./MysqL_install_db --basedir=/data/MysqL56 --datadir=/MysqL-instance/3308/data --user=MysqL> ./MysqL_install_db --basedir=/data/MysqL56 --datadir=/MysqL-instance/3309/data --user=MysqL

 
八、启动MysqL多实例

> /MysqL-instance/3308/MysqL start> /MysqL-instance/3309/MysqL start> netstat -lntup|grep 330


九、登陆MysqL实例

> MysqL -uroot -p -S /MysqL-instance/3308/MysqL.sock

 

总结

以上是内存溢出为你收集整理的centos7下创建mysql5.6多实例全部内容,希望文章能够帮你解决centos7下创建mysql5.6多实例所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1164679.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存