mysql restore slave from master dump

On the master:

RESET MASTER;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS \G;
Copy and paste the result
mysql> show master status \G;
*************************** 1. row ***************************
File: mysql-bin.000001
Position: 28808
Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.00 sec)

you’ll need file and position to point the slave on the correct binlog position

mysqldump - u root -p dbname > /usr/local/src/dump.sql
UNLOCK TABLES;

On the slave;

STOP SLAVE;
scp root@masteraddress:/usr/local/src/dump.sql /usr/local/src
mysql -u root -p < /usr/local/src/dump.sql
RESET SLAVE;
now remember to use what you got from the master status
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=28808;
START SLAVE;

and check with
SHOW SLAVE STATUS \G;

Slave_IO_Running: Yes
Slave_SQL_Running: Yes

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s