rm -rf master/ scripts/mysql_install_db --basedir=$PWD --datadir=$PWD/master -v bin/mysqld --basedir=$PWD --datadir=$PWD/master --log-bin --server_id=1 --socket=/tmp/mysql_master.sock --master-info-repository=TABLE --port=3306 --log-error=$PWD/master/log.err 2>&1 & rm -rf slave/ scripts/mysql_install_db --basedir=$PWD --datadir=$PWD/slave -v bin/mysqld --basedir=$PWD --datadir=$PWD/slave --log-bin --server_id=2 --sync-master-info=1 --master-info-repository=TABLE --relay-log-info-repository=TABLE --replicate-ignore-db=example --socket=/tmp/mysql_slave.sock --port=3307 --log-error=$PWD/slave/log.err 2>&1 & -- MasterA [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.6.35: bin/mysql -uroot -S /tmp/mysql_master.sock --prompt='MasterA>' Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.35-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MasterA>select * from mysql.slave_master_info; Empty set (0.01 sec) MasterA>change master to master_host='IDoNotExist', master_port=3306, master_user='blah', master_password='blah', master_log_file='IDoNotExist', master_log_pos=1; Query OK, 0 rows affected, 2 warnings (0.00 sec) MasterA>select * from mysql.slave_master_info\G *************************** 1. row *************************** Number_of_lines: 23 Master_log_name: IDoNotExist Master_log_pos: 4 Host: IDoNotExist User_name: blah User_password: blah Port: 3306 Connect_retry: 60 Enabled_ssl: 0 Ssl_ca: Ssl_capath: Ssl_cert: Ssl_cipher: Ssl_key: Ssl_verify_server_cert: 0 Heartbeat: 1800 Bind: Ignored_server_ids: 0 Uuid: Retry_count: 86400 Ssl_crl: Ssl_crlpath: Enabled_auto_position: 0 1 row in set (0.00 sec) -- Take a dump of MasterA, restore on MasterB(slave) [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.6.35: bin/mysqldump -uroot -S /tmp/mysql_master.sock --all-databases --flush-logs --master-data=2 > MasterA.sql [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.6.35: [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.6.35: bin/mysql -uroot -S /tmp/mysql_slave.sock < MasterA.sql [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.6.35: -- Take a note of coordinates on masterA MasterA>CREATE USER 'repl'@'localhost' IDENTIFIED BY 'slavepass'; Query OK, 0 rows affected (0.00 sec) MasterA>GRANT REPLICATION SLAVE ON *.* TO 'repl'@'localhost'; Query OK, 0 rows affected (0.00 sec) MasterA> MasterA>CREATE USER 'repl'@'127.0.0.1' IDENTIFIED BY 'slavepass'; Query OK, 0 rows affected (0.00 sec) MasterA>GRANT REPLICATION SLAVE ON *.* TO 'repl'@'127.0.0.1'; Query OK, 0 rows affected (0.00 sec) MasterA>FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) MasterA>show master status\G *************************** 1. row *************************** File: hod03-bin.000002 Position: 813 Binlog_Do_DB: Binlog_Ignore_DB: Executed_Gtid_Set: 1 row in set (0.00 sec) --MasterB Instruct MasterB to connect MasterA [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.6.35: bin/mysql -uroot -S /tmp/mysql_slave.sock --prompt='MasterB>' Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.35-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MasterB>CHANGE MASTER TO -> MASTER_HOST='localhost', -> MASTER_PORT=3306, -> MASTER_USER='repl', -> MASTER_PASSWORD='slavepass', -> MASTER_LOG_FILE='hod03-bin.000002', -> MASTER_LOG_POS=813; Query OK, 0 rows affected, 2 warnings (0.01 sec) MasterB>START SLAVE; Query OK, 0 rows affected (0.00 sec) MasterB>SHOW SLAVE STATUS\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: localhost Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: hod03-bin.000002 Read_Master_Log_Pos: 813 Relay_Log_File: hod03-relay-bin.000002 Relay_Log_Pos: 283 Relay_Master_Log_File: hod03-bin.000002 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: example Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 813 Relay_Log_Space: 456 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 Master_UUID: 6b52b3c0-0e19-11e7-b421-0010e05f3e06 Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 1 row in set (0.00 sec) MasterB> -- 2 rows exists in mysql.slave_master_info MasterB>select * from mysql.slave_master_info\G *************************** 1. row *************************** Number_of_lines: 23 Master_log_name: IDoNotExist Master_log_pos: 4 Host: IDoNotExist User_name: blah User_password: blah Port: 3306 Connect_retry: 60 Enabled_ssl: 0 Ssl_ca: Ssl_capath: Ssl_cert: Ssl_cipher: Ssl_key: Ssl_verify_server_cert: 0 Heartbeat: 1800 Bind: Ignored_server_ids: 0 Uuid: Retry_count: 86400 Ssl_crl: Ssl_crlpath: Enabled_auto_position: 0 *************************** 2. row *************************** Number_of_lines: 23 Master_log_name: hod03-bin.000002 Master_log_pos: 813 Host: localhost User_name: repl User_password: slavepass Port: 3306 Connect_retry: 60 Enabled_ssl: 0 Ssl_ca: Ssl_capath: Ssl_cert: Ssl_cipher: Ssl_key: Ssl_verify_server_cert: 0 Heartbeat: 1800 Bind: Ignored_server_ids: 0 Uuid: 6b52b3c0-0e19-11e7-b421-0010e05f3e06 Retry_count: 86400 Ssl_crl: Ssl_crlpath: Enabled_auto_position: 0 2 rows in set (0.00 sec) -- MatserA MasterA>create database db1; Query OK, 1 row affected (0.00 sec) MasterA>create database db2; Query OK, 1 row affected (0.00 sec) MasterA>show databases; +--------------------+ | Database | +--------------------+ | information_schema | | db1 | | db2 | | mysql | | performance_schema | | test | +--------------------+ 6 rows in set (0.00 sec) -- MatserB MasterB>show databases; +--------------------+ | Database | +--------------------+ | information_schema | | db1 | | db2 | | mysql | | performance_schema | | test | +--------------------+ 6 rows in set (0.00 sec) MasterB>SHOW SLAVE STATUS\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: localhost Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: hod03-bin.000002 Read_Master_Log_Pos: 995 Relay_Log_File: hod03-relay-bin.000002 Relay_Log_Pos: 465 Relay_Master_Log_File: hod03-bin.000002 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: example Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 995 Relay_Log_Space: 638 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 Master_UUID: 6b52b3c0-0e19-11e7-b421-0010e05f3e06 Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 1 row in set (0.00 sec) MasterB> ### Restart MasterB i.e slave MasterB>\q Bye [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.6.35: bin/mysqladmin -uroot -S /tmp/mysql_slave.sock shutdown [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.6.35: bin/mysqld --basedir=$PWD --datadir=$PWD/slave --log-bin --server_id=2 --sync-master-info=1 --master-info-repository=TABLE --relay-log-info-repository=TABLE --replicate-ignore-db=example --socket=/tmp/mysql_slave.sock --port=3307 --log-error=$PWD/slave/log.err 2>&1 & [1] 19163 [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.6.35: 2017-03-21 10:47:11 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-03-21 10:47:11 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled 2017-03-21 10:47:11 0 [Note] bin/mysqld (mysqld 5.6.35-enterprise-commercial-advanced-log) starting as process 19163 ... [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.6.35: bin/mysql -uroot -S /tmp/mysql_slave.sock --prompt='MasterB>' Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.6.35-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MasterB>SHOW SLAVE STATUS\G *************************** 1. row *************************** Slave_IO_State: Connecting to master Master_Host: IDoNotExist Master_User: blah Master_Port: 3306 Connect_Retry: 60 Master_Log_File: IDoNotExist Read_Master_Log_Pos: 4 Relay_Log_File: hod03-relay-bin.000003 Relay_Log_Pos: 4 Relay_Master_Log_File: hod03-bin.000002 Slave_IO_Running: Connecting Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: example Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 995 Relay_Log_Space: 120 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 2005 Last_IO_Error: error connecting to master 'blah@IDoNotExist:3306' - retry-time: 60 retries: 1 Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 0 Master_UUID: Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: 170321 10:47:11 Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 1 row in set (0.00 sec) Finally, MasterB>SHOW SLAVE STATUS\G *************************** 1. row *************************** Slave_IO_State: Connecting to master Master_Host: IDoNotExist Master_User: blah Master_Port: 3306 Connect_Retry: 60 Master_Log_File: IDoNotExist Read_Master_Log_Pos: 4 Relay_Log_File: hod03-relay-bin.000003 Relay_Log_Pos: 4 Relay_Master_Log_File: hod03-bin.000002 Slave_IO_Running: Connecting Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: example Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 995 Relay_Log_Space: 120 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 2005 Last_IO_Error: error connecting to master 'blah@IDoNotExist:3306' - retry-time: 60 retries: 1 Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 0 Master_UUID: Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: 170321 10:47:11 Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 1 row in set (0.00 sec)