日期:2014-05-16  浏览次数:20660 次

linux 多个Mysql安装
1. 初始化数据库
script/mysql_install_db --basedir=xxx --datadir=xxx

2. cp support-file/my-medium.cnf $basedir/my.cnf
修改my.cnf
[mysqld]
basedir=xxx
datadir=xxx
socket=/tmp/mysqlxxx.sock
port=xxx

3. cp support-file/mysql.server /etc/init.d/mysqlxxx
修改mysqlxxx
basedir=xxx
datadir=xxx

4. service mysqlxxx start

5. 登录./mysql -uroot -S /tmp/mysqlxxx.sock

主从库配置:

1. 修改配置文件
master

修改my.cnf
引用
server-id=3
log-bin=mysql-bin
binlog-do-db=mmusic


slave
修改my.cnf
引用
server-id=4
#仅同步单个表
replicate-wild-do-table=mmusic.users
replicate-wild-do-table=mmusic.smsconfiginfo

2. 对应用户

master 命令行
引用
grant replication slave on *.* to root@'%' identified by 'slave';
flush privileges;
show master status;


slave  命令行
引用
reset slave;

CHANGE MASTER TO MASTER_HOST='122.227.164.118', MASTER_PORT=3603, MASTER_USER='root', MASTER_PASSWORD='slave',MASTER_LOG_FILE='mysql-bin.000009',MASTER_LOG_POS= 107;

slave start;

show slave status;