-- Setup replication rm -rf master bin/mysqld --initialize-insecure --basedir=/export/umesh/server/binaries/GABuilds/mysql-5.7.17 --datadir=/export/umesh/server/binaries/GABuilds/mysql-5.7.17/master -v bin/mysqld --no-defaults --basedir=/export/umesh/server/binaries/GABuilds/mysql-5.7.17 --datadir=/export/umesh/server/binaries/GABuilds/mysql-5.7.17/master --core-file --socket=/tmp/mysql_master.sock --port=3306 --log-error=/export/umesh/server/binaries/GABuilds/mysql-5.7.17/master/log.err --log-bin=master-bin --server_id=1 2>&1 & rm -rf slave bin/mysqld --initialize-insecure --basedir=/export/umesh/server/binaries/GABuilds/mysql-5.7.17 --datadir=/export/umesh/server/binaries/GABuilds/mysql-5.7.17/slave -v bin/mysqld --no-defaults --basedir=/export/umesh/server/binaries/GABuilds/mysql-5.7.17 --datadir=/export/umesh/server/binaries/GABuilds/mysql-5.7.17/slave --core-file --socket=/tmp/mysql_slave.sock --port=3307 --log-error=/export/umesh/server/binaries/GABuilds/mysql-5.7.17/slave/log.err --log-bin=slave-bin --server_id=2 --skip_slave_start 2>&1 & -- master [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.17: bin/mysqld --no-defaults --basedir=/export/umesh/server/binaries/GABuilds/mysql-5.7.17 --datadir=/export/umesh/server/binaries/GABuilds/mysql-5.7.17/slave --core-file --socket=/tmp/mysql_slave.sock --port=3307 --log-error=/export/umesh/server/binaries/GABuilds/mysql-5.7.17/slave/log.err --log-bin=slave-bin --server_id=2 --skip_slave_start 2>&1 & [2] 2650 [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.17: [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.17: [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.17: bin/mysql -uroot -S /tmp/mysql_master.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17-log MySQL Community Server (GPL) 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. root@localhost [(none)]> CREATE USER 'repl'@'localhost' IDENTIFIED BY 'slavepass'; Query OK, 0 rows affected (0.00 sec) root@localhost [(none)]> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'localhost'; Query OK, 0 rows affected (0.00 sec) root@localhost [(none)]> root@localhost [(none)]> CREATE USER 'repl'@'127.0.0.1' IDENTIFIED BY 'slavepass'; Query OK, 0 rows affected (0.00 sec) root@localhost [(none)]> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'127.0.0.1'; Query OK, 0 rows affected (0.00 sec) root@localhost [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) root@localhost [(none)]> show master status; +-------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +-------------------+----------+--------------+------------------+-------------------+ | master-bin.000001 | 1220 | | | | +-------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec) -- slave [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.17: bin/mysql -uroot -S /tmp/mysql_slave.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17-log MySQL Community Server (GPL) 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. root@localhost [(none)]> CHANGE MASTER TO -> MASTER_HOST='localhost', -> MASTER_PORT=3306, -> MASTER_USER='repl', -> MASTER_PASSWORD='slavepass', -> MASTER_LOG_FILE='master-bin.000001', -> MASTER_LOG_POS=1220; Query OK, 0 rows affected, 2 warnings (0.01 sec) root@localhost [(none)]> start slave; Query OK, 0 rows affected (0.00 sec) root@localhost [(none)]> 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: master-bin.000001 Read_Master_Log_Pos: 1220 Relay_Log_File: hod03-relay-bin.000002 Relay_Log_Pos: 321 Relay_Master_Log_File: master-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: 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: 1220 Relay_Log_Space: 528 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: db574d79-decd-11e6-9f2d-0010e05f3e06 Master_Info_File: /export/umesh/server/binaries/GABuilds/mysql-5.7.17/slave/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates 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 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 1 row in set (0.00 sec) -- master root@localhost [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) root@localhost [(none)]> show master status; +-------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +-------------------+----------+--------------+------------------+-------------------+ | master-bin.000001 | 1220 | | | | +-------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec) root@localhost [(none)]> flush logs; Query OK, 0 rows affected (0.00 sec) root@localhost [(none)]> CREATE USER 'testuser'@'%'; Query OK, 0 rows affected (0.00 sec) root@localhost [(none)]> grant proxy on test2 to testuser; Query OK, 0 rows affected (0.00 sec) root@localhost [(none)]> show binlog events in 'master-bin.000002'; +-------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info | +-------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+ | master-bin.000002 | 4 | Format_desc | 1 | 123 | Server ver: 5.7.17-log, Binlog ver: 4 | | master-bin.000002 | 123 | Previous_gtids | 1 | 154 | | | master-bin.000002 | 154 | Anonymous_Gtid | 1 | 219 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS' | | master-bin.000002 | 219 | Query | 1 | 356 | CREATE USER 'testuser'@'%' IDENTIFIED WITH 'mysql_native_password' | | master-bin.000002 | 356 | Anonymous_Gtid | 1 | 421 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS' | | master-bin.000002 | 421 | Query | 1 | 556 | GRANT USAGE ON *.* TO 'test2'@'%','testuser'@'%' | +-------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+ 6 rows in set (0.00 sec) root@localhost [(none)]> select user,host from mysql.user where user like 'test%'; +----------+------+ | user | host | +----------+------+ | testuser | % | +----------+------+ 1 row in set (0.00 sec) -- slave root@localhost [(none)]> 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: master-bin.000002 Read_Master_Log_Pos: 556 Relay_Log_File: hod03-relay-bin.000004 Relay_Log_Pos: 571 Relay_Master_Log_File: master-bin.000002 Slave_IO_Running: Yes Slave_SQL_Running: No Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 1133 Last_Error: Error 'Can't find any matching row in the user table' on query. Default database: ''. Query: 'GRANT USAGE ON *.* TO 'test2'@'%','testuser'@'%'' Skip_Counter: 0 Exec_Master_Log_Pos: 356 Relay_Log_Space: 1026 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: NULL Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 1133 Last_SQL_Error: Error 'Can't find any matching row in the user table' on query. Default database: ''. Query: 'GRANT USAGE ON *.* TO 'test2'@'%','testuser'@'%'' Replicate_Ignore_Server_Ids: Master_Server_Id: 1 Master_UUID: db574d79-decd-11e6-9f2d-0010e05f3e06 Master_Info_File: /export/umesh/server/binaries/GABuilds/mysql-5.7.17/slave/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: 170120 06:05:48 Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 1 row in set (0.00 sec) root@localhost [(none)]>