mysql多实例运行

1.复制cnf文件,

cp my.cnf my_muti.cnf

2.编辑my_muti.cnf文件

[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user=mysql


[mysqld1]


port = 3306


socket = /tmp/mysql3306.sock


basedir=/usr/local/mysql


datadir=/usr/local/mysql/data3306


log-bin=mysql-bin


[mysqld2]


port = 3307


socket = /tmp/mysql3307.sock


basedir=/usr/local/mysql


datadir=/usr/local/mysql/data3307


log-bin=mysql-bin


必须初始化数据库目录:

  1. shell>cd /usr/local/mysql/;./scripts/mysql_install_db --datadir=/usr/local/mysql/data3307/ --user=mysql

  2. shell>cd /usr/local/mysql/;./scripts/mysql_install_db --datadir=/usr/local/mysql/data3306/ --user=mysql


查询是否启动: mysqld_multi --defaults-extra-file=/etc/my_muti.cnf report

启动:

mysqld_multi --defaults-extra-file=/etc/my_muti.cnf start


初始话成功,会提示OK,否则查看数据库目录是否有权限


本机登录Mysql,如3307端口:


  1. shell>mysql -S /tmp/mysql3307.sock

  2. mysql> show variables like 'datadir';

  3. +---------------+----------------------+

  4. | Variable_name | Value |

  5. +---------------+----------------------+

  6. | datadir | /mysqldata/data3307/ |

  7. +---------------+----------------------+

  8. 1 row in set (0.00 sec)

4关闭数据库实例


  1. shell>/usr/local/mysql/bin/mysqld_multi stop 1-2


  2. shell>/usr/local/mysql/bin/mysqld_multi stop 1

  3. shell>/usr/local/mysql/bin/mysqld_multi stop 2






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值