- mkdir -p /data/master
- mkdir -p /data/slave
- mkdir -p /data/master_binlog
- mkdir -p /data/slave_binlog
- mkdir /var/log/mysql1
- mkdir/var/log/mysql2
- chown mysql.mysql /data/master -R
- chown mysql.mysql /data/slave -R
- chmod 777 /var/log/mysql1
- chmod 777/var/log/mysql2
- chmod 777 /var/lib/mysql
/usr/local/mysql/scripts/mysql_install_db--datadir=/data/master
/usr/local/mysql/scripts/mysql_install_db--datadir=/data/slave
4. 安装工具
5.修改环境变量
- cp /usr/local/mysql/bin/my_print_defaults /usr/bin/
- cp /usr/local/mysql/bin/mysqld_multi /usr/bin
1.mysql启动
应县网站建设公司创新互联,应县网站设计制作,有大型网站制作公司丰富经验。已为应县上千提供企业网站建设服务。企业网站搭建\外贸网站建设要多少钱,请找那个售后服务好的应县做网站的公司定做!
- mysqld_multi start 1 启动实例1
- mysqld_multi start 1-2 启动实例1,2
2.命令行登陆
- mysql -u your_user -p your_password -P3307 -S /tmp/mysql3307.sock
由于涉及权限问题,mysqld_multi不能控制关闭mysql多实例,自己写了个关闭脚本#!/bin/bashuser=""password=""read -p "Please input mysqld ID 1-2:" IDif [ "$ID" == "1" ]; then#read -p "Please input mysqld port number 3306-3307:" port/usr/local/mysql/bin/mysqladmin -u$user -p$password -S /var/lib/mysql/mysql3306.sock shutdown && echo "close mysqld master successful"elif [ "$ID" == "2" ]; then/usr/local/mysql/bin/mysqladmin -u$user -p$password -S /var/lib/mysql/mysql3307.sock shutdown && echo "close mysqld slave successful"elseecho "Please input mysqld ID 1-2:"fi