免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1139 | 回复: 0

使用mysqld_multi管理多个MySQL实例 [复制链接]

论坛徽章:
0
发表于 2011-12-23 02:41 |显示全部楼层
1. 修改mysql的配置文件my.cnf配置mysqld_multi的选项

  1. [mysqld_multi]
    mysqld          = /usr/local/mysql/bin/mysqld_safe
    mysqladmin      = /usr/local/mysql/bin/mysqladmin
    user            = multi_admin
    password        = multi_passwd


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

 

5. 之前在my.cnf设置的user和password是用来关闭数据库实例的,根据配置中的用户名和密码授权该用户shutdown权限

 

  1. mysql -uroot -S /tmp/mysql1.sock -e 'grant SHUTDOWN ON *.* TO multi_admin@localhost identified by "multi_passwd";'

  2. mysql -uroot -S /tmp/mysql2.sock -e 'grant SHUTDOWN ON *.* TO multi_admin@localhost identified by "multi_passwd";'

  3. mysql -uroot -S /tmp/mysql3.sock -e 'grant SHUTDOWN ON *.* TO multi_admin@localhost identified by "multi_passwd";'

 

6. 关闭数据库实例

 

mysqld_multi stop 1-3

mysqld_multi stop 1

mysqld_multi stop 2

mysqld_multi stop 3

 

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP