分类:
2011-10-26 12:33:26
原文地址:使用mysqld_multi管理多个MySQL实例 作者:anmile
2.修改mysql的配置文件my.cnf 创建mysqld_multi的config-file
[mysqld1]
port = 3306
socket = /tmp/mysql1.sock
datadir = /var/lib/mysql1
user = mysql
[mysqld2]
port = 3307
socket = /tmp/mysql2.sock
datadir = /var/lib/mysql2
user = mysql
[mysqld3]
port = 3308
socket = /tmp/mysql3.sock
datadir = /var/lib/mysql3
user = mysql
3. 初始化数据库
/usr/local/mysql/scripts/mysql_install_db --datadir=/var/lib/mysql1 --user=mysql
/usr/local/mysql/scripts/mysql_install_db --datadir=/var/lib/mysql2 --user=mysql
/usr/local/mysql/scripts/mysql_install_db --datadir=/var/lib/mysql3 --user=mysql
4. 启动多实例
mysqld_multi start 1-3
或
mysqld_multi start 1
mysqld_multi start 2
mysqld_multi start 3
6. 关闭数据库实例
mysqld_multi stop 1-3
或
mysqld_multi stop 1
mysqld_multi stop 2
mysqld_multi stop 3