mysql 添加实例_如何在多实例基础上再添加一个mysql的实例

1)创建数据文件所需的目录# mkdir -p /data/3308/data

# cp /data/3306/my.cnf /data/3308

# cp /data/3306/mysql /data/3308

2)配置权限# chown mysql.mysql /data/3308 -R

# chown root.root /data/3308/mysql

# chmod 700 /data/3308/mysql

3)修改数据配置文件及启动脚本# sed -i 's/3306/3308/g' /data/3308/my.cnf

# sed -i 's/server-id = 1/server-id = 8/g' /data/3308/my.cnf

# cat my.cnf | grep id

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

server-id = 8

pid-file=/data/3308/mysqld.pid

# sed -i 's/3306/3308/g' /data/3308/mysql

# cd /application/mysql/scripts/

# ./mysql_install_db --datadir=/data/3308/data --basedir=/application/mysql --user=mysql

# /data/3308/mysql start

Starting MySQL...

# echo $?

0

4)检查数据库的运行情况# netstat -tunlp | grep 330*

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      4052/mysqld

tcp        0      0 0.0.0.0:3307                0.0.0.0:*                   LISTEN      4048/mysqld

tcp        0      0 0.0.0.0:3308                0.0.0.0:*                   LISTEN      5502/mysqld

5)配置数据库开机自动启动# echo "/data/3308/mysql start">>/etc/rc.local

# tail -4 /etc/rc.local

显示的结果如下:

# mysql multi instances startup

/data/3306/mysql start

/data/3307/mysql start

/data/3308/mysql start

6)初始化数据库设置mysql初始密码:

# mysqladmin -u root -S /data/3308/mysql.sock password 'redhat12345'

# mysql -u root -S /data/3308/mysql.sock -predhat12345

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.5.32-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值