MySQL主从复制
[mysqld] log-bin=mysql-bin server-id=1
innodb_flush_log_at_trx_commit=1
sync_binlog=1
[mysqld] server-id=2
mysql>CREATE USER ‘repl‘@‘%.mydomain.com‘ IDENTIFIED BY ‘slavepass‘;
mysql>GRANT REPLICATION SLAVE ON *.* TO ‘repl‘@‘%.mydomain.com‘;
mysql> FLUSH PRIVILEGES;
mysql> FLUSH TABLES WITH READ LOCK;
mysql > SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000003 | 73 | test | manual,mysql |
+------------------+----------+--------------+------------------+
mysql> UNLOCK TABLES;
shell> mysqldump -uroot -p --all-databases --master-data > dbdump.db
shell> mysql -uroot -p < dbdump.db
mysql>CHANGE MASTER TO
->MASTER_HOST=‘
->master_host_name
‘,MASTER_USER=‘
->replication_user_name
‘,MASTER_PASSWORD=‘
->replication_password
‘,MASTER_LOG_FILE=‘
->recorded_log_file_name
‘,MASTER_LOG_POS=
recorded_log_position
;
mysql> START SLAVE;
mysql> STOP SLAVE;
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。