您的位置:首页 > 数据库 > MySQL

debian mysql 主从复制

2012-05-07 18:59 375 查看


安装数据库

主IP 192.168.0.59

辅助:IP 192.168.0.60

apt-get install mysql-server mysql-client

修改my.cnf见附件

1.mysql_install_db --user=mysql --datadir=/home/data/db/mysql

2.cat /etc/mysql/debian.cnf |grep password |head -n 1|awk '{print $3}'

oaoUdbzsGY0f4cgO

3.登入mysql执行

>GRANT ALL ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY PASSWORD 'oaoUdbzsGY0f4cgO';

use mysql

update user set Password = password('oaoUdbzsGY0f4cgO') where User='debian-sys-maint';

FLUSH PRIVILEGES;

初始化完毕

mysql>

grant replication slave on *.* to 'repl_user'@'192.168.0.60' identified by 'repl_123';

show master status;

mysql> show master status;

+------------------+----------+--------------+--------------------------+

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+------------------+----------+--------------+--------------------------+

| mysql-bin.000003 | 193 | | mysql,information_schema |

+------------------+----------+--------------+--------------------------+

1 row in set (0.00 sec)

辅助:安装数据库已经初始化数据库同上

修改my.cnf见附件

mysql>

change master to master_host=192.168.0.59',master_user='repl_user',master_password='repl_123',master_port=3306,master_log_file='mysql-bin.000003',master_log_pos=193;

slave start;

show slave status\G

附件:http://down.51cto.com/data/2360508
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  debian mysql主从