时间:2021-07-01 10:21:17 帮助过:16人阅读
一台服务上已经安装了mysql实例,可通过mysqld_multi命令新增实例1.假设该服务器上有一原有mysql实例,其basedir为/usr/local/m
一台服务上已经安装了mysql实例,可通过mysqld_multi命令新增实例
1.假设该服务器上有一原有mysql实例,,其basedir为/usr/local/mysql, 其数据目录为/usr/local/mysql/data,配置文件为/etc/my.cnf
# mkdir /opt/mysql3308
# cp –rfp /usr/local/data/mysql /opt/mysql3308/
# 假设这个新建的实例其数据目录放在/opt/mysql3308
这一步了。
# chown –R mysql:mysql /opt/mysql3308
# vi /etc/my.cnf
在文件的一开头,进行如此设置,保存退出.
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user=root
password=12345678
这两行就不需要书写.
log = /usr/local/mysql/data/mysqld_multi.log
user=mysql
pid-file=/tmp/3308.pid
port=3308
socket=/tmp/mysql3308.sock
basedir=/usr/local/mysql
datadir=/opt/mysql3308
#server-id=3308 # 此参数server-id在设置数据库主从复制时可以启用
# Example MySQL config file for large systems.
#
# This is for a large system with memory = 512M where the system runs mainly
# MySQL.
# mysqld_multi start 2
# 启动该新增新例
此时netstat –ntl,应该可以看到3308端口已经启动
ps –ef|grep mysql,应该可以该新增实例的参数。
# ./bin/mysql –uroot –S /tmp/mysql3308.sock
# 该命令为连接该数据库实例.