lzf79 发表于 2018-5-15 09:54:03

debian mysql 主从复制

  主
安装数据库
  主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
页: [1]
查看完整版本: debian mysql 主从复制