<\/span><\/h4>\nMySQL slave must be configured to start replication from the correct point, To do this task successfully you must note down master’s current coordinates with its binary log info. To collect MYSQL master binary log coordinates please FLUSH TABLES WITH READ LOCK, which blocks COMMIT operations for InnoDB tables (data consistency in replication is very important )Please run the below SQL in MySQL master – 192.168.56.11<\/p>\n
mysql> FLUSH TABLES WITH READ LOCK;\r\n<\/pre>\nNow from different MySQL session on the master run SHOW MASTER STATUS statement to collect current binary log file name and it’s position<\/p>\n
mysql > SHOW MASTER STATUS;\r\n+------------------+----------+--------------+------------------+\r\n| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |\r\n+------------------+----------+--------------+------------------+\r\n| mysql-bin.000147 | 450 | sakila | manual,mysql |\r\n+------------------+----------+--------------+------------------+\r\n<\/pre>\nThis is the position (Position 450) from which the slave database will start replication, Take a note the number as you need them while setting up slave for MySQL replication. Now you are ready to proceed with exporting your database using mysqldump from a new window \u00a0( please confirm you are not typing this command from MySQL, It’s done from bash shell )<\/p>\n
mysqldump -u root -p --opt sakila > sakila-backup.sql<\/pre>\nNow unlock tables in the master<\/p>\n
UNLOCK TABLES;<\/pre>\n<\/span>Restore the mysqldump backup to slave (192.168.56.12)<\/span><\/h4>\nmysql -u root -p sakila < sakila-backup.sql\r\n<\/pre>\n<\/span>Connecting slave to master<\/span><\/h4>\nRun the script below from MySQL terminal in the slave<\/p>\n
CHANGE MASTER TO \r\nMASTER_HOST='192.168.56.11', \r\nMASTER_USER='repl', \r\nMASTER_PASSWORD='MySQLDBA19\/47', \r\nMASTER_LOG_FILE='mysql-bin.000147', \r\nMASTER_LOG_POS= 450;\r\n<\/pre>\n