(转) centos7下创建mysql5.6多实例

原文:http://blog.csdn.net/a1010256340/article/details/77483504

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

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


1

2

mkdir -p /mysql-instance/3308/data

mkdir -p /mysql-instance/3309/data

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


1

2

> 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

四、修改配置文件


1

2

> vi /mysql-instance/3308/my.cnf

> vi /mysql-instance/3309/my.cnf


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

[client]

port = 3308

socket = /mysql-instance/3308/mysql.sock

[mysql]

no-auto-rehash

[mysqld]

user = mysql

port = 3308

socket = /mysql-instance/3308/mysql.sock

basedir = /data/mysql56

datadir = /mysql-instance/3308/data

pid-file = /mysql-instance/3308/mysql.pid

relay-log = /mysql-instance/3308/relay-bin

relay-log-info-file = /mysql-instance/3308/relay-log.info

server-id = 12

[mysqld_safe]

log-error = /mysql-instance/3308/mysql.err

pid-file = /mysql-instance/3308/mysql.pid

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

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


1

2

> vi /mysql-instance/3308/mysql

> vi /mysql-instance/3309/mysql


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

#!/bin/sh

port=3308

mysql_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 $1 in

    start) mysql_start ;;

    stop) mysql_stop ;;

    restart) mysql_restart ;;

*)

printf "usage: /data/${port}/mysql {start|stop|restart}\n"

esac

六、授权mysql用户目录权限


1

2

3

chown -R mysql.mysql /mysql-instance

chmod 700 /mysql-instance/3308/mysql

chmod 700 /mysql-instance/3309/mysql

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


1

2

3

> 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多实例


1

2

3

> /mysql-instance/3308/mysql start

> /mysql-instance/3309/mysql start

> netstat -lntup|grep 330

九、登陆mysql实例


1

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

时间: 2024-10-11 18:01:35

(转) centos7下创建mysql5.6多实例的相关文章

centos7下创建mysql5.6多实例

一.mysql安装目录说明mysql5.6以二进制安装包安装在/data/mysql56下数据目录为/data/mysql56/data下配置文件为/etc/my.cnf下 二.多实例目录说明/mysql-instance         |-- 3308                  |-- data  #3308实例数据目录         |-- 3309                  |-- data  #3309实例数据目录 > mkdir -p /mysql-instance

CentOS-7下安装MySQL5.6.22

CentOS7下安装MySQL5.6.22(当前最新版本:2015-01-17) 转载请注明出处:jiq?钦's technical Blog 一  安装环境 (1)CentOS版本:CentOS-7 查看方法: [[email protected] 桌面]# cat /etc/redhat-release CentOS Linux release 7.0.1406 (Core) 来源:官网下载 下载地址:http://www.centos.org/ (2)MySQL版本:MySQL-5.6.2

CentOS7下安装MySQL5.7安装与配置(YUM)

CentOS7下安装MySQL5.7安装与配置(YUM) 安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1.配置YUM源 在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo/yum/ # 下载mysql源安装包shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm# 安装mysql源shell> yum l

如何在Centos7下安装MySQL5.7

Centos7下安装MySQL5.7 在CentOS中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB. 1.安装mysql (由于yum源上没有mysql-server.所以必须去官网下载,这里 我们用wget命令,直接获取)wget -i -chttp://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm 2.安装mysql的依赖包

Centos7下安装mysql5.7.16

mysql的安装(root用户下) 从官网下载软件 linux下必须安装系统对应的版本,多少位 必须安装的是:server,client 但是我可不管要安装那个插件,我们直接使用bundle版本(就是各个插件都有) mysql的版本随意,反正我下载的是最新版的:mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar rpm安装 卸载掉老版的mysql 查询是否有老的mysql rpm -qa | grep mysql rpm -qa|grep mariadb(这条命令下

CentOS-7下安装MySQL5.6.22(转)

转: http://www.2cto.com/database/201501/371451.html 一 安装环境 (1)CentOS版本:CentOS-7 查看方法: [[email protected] 桌面]# cat /etc/redhat-release CentOS Linux release 7.0.1406 (Core) 来源:官网下载 下载地址:http://www.centos.org/ (2)MySQL版本:MySQL-5.6.22 来源:官网下载 下载地址:https:/

CentOS7下安装MySQL5.7安装与配置(转)

原文地址:http://www.centoscn.com/mysql/2016/0626/7537.html 安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1.配置YUM源 在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo/yum/  # 下载mysql源安装包 shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarc

CentOS-7下安装MySQL5.6.22(转发)

一 安装环境 (1)CentOS版本:CentOS-7 查看方法: [[email protected] 桌面]# cat /etc/redhat-release CentOS Linux release 7.0.1406 (Core) 来源:官网下载 下载地址:http://www.centos.org/ (2)MySQL版本:MySQL-5.6.22 来源:官网下载 下载地址:https://edelivery.oracle.com/EPD/Search/handle_go 或者http:/

centos7下systemd实现tomcat多实例

环境: CentOS 7 x86_64 1.安装jdk 1 rpm -ivh jdk-8u60-linux-x64.rpm 2.创建普通用户 1 2 getent group tomcat || groupadd -r tomcat getent passwd tomcat || useradd -r -d /opt -s /bin/nologin tomcat 3.下载tomcat 7 1 2 3 4 5 6 7 8 9 cd /opt wget http: //mirrors .ustc.e