时间:2021-07-01 10:21:17 帮助过:62人阅读
./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ &
cp ../support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
mv /etc/my.cnf /etc/my.cnf_bak
cp ../support-files/my-default.cnf /etc/my.cnf
将以下加入my.cnf:
log-bin=mysql-bin
server-id=1
innodb_flush_log_at_trx_commit=1
sync_binlog=1
#binlog-do-db=mysql
#binlog_ignore_db=mysql
不加以上注释两行,标识复制全部数据库
重启mysql
创建slave用户:
create user ‘slave‘@10.0.0.3 identified by ‘slave‘;
grant replication slave on *.* to salve@10.0.0.3 identified by ‘salve‘;
flush tables with read lock; 执行以下命令锁定数据库以防止写入数据
不要关闭现在窗口,新开一个窗口:
mysqldump -uroot -p --all-databases>all.sql
mysql -uroot -p
show master status; 记住
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 494 | mysql | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
然后在锁定数据库表窗口解锁:
unlock tables;
从数据库:
mysql -uroot -p <all.sql
mysql> change master to
-> master_host=‘10.0.0.2‘,
-> master_user=‘salve‘,
-> master_password=‘salve‘,
-> master_port=3306,
-> master_log_file=‘mysql-bin.000001‘,
-> master_log_pos=494,
-> master_connect_retry=10;
新建mysql数据库测试同步
本文出自 “大王好帅” 博客,请务必保留此出处http://dawang.blog.51cto.com/4927689/1657975
mysql同步复制
标签:mysql local