One way to create a snapshot of the data in an existing master database is to use the mysqldump tool to create a dump of all the databases you want to replicate. Once the data dump has been completed, you then import this data into the slave before starting the replication process.
The example shown here dumps all databases to a file named
dbdump.db, and includes the
--master-data option which
automatically appends the CHANGE MASTER
TO statement required on the slave to start the
replication process:
shell> mysqldump --all-databases --master-data > dbdump.db
If you do not use
--master-data, then it is
necessary to lock all tables in a separate session manually
(using FLUSH TABLES WITH
READ LOCK) prior to running
mysqldump, then exiting or running UNLOCK
TABLES from the second session to release the locks. You must
also obtain binary log position information matching the
snapshot, using SHOW MASTER
STATUS, and use this to issue the appropriate
CHANGE MASTER TO statement when
starting the slave.
When choosing databases to include in the dump, remember that you need to filter out databases on each slave that you do not want to include in the replication process.
To import the data, either copy the dump file to the slave, or access the file from the master when connecting remotely to the slave.
mysqldump --user=abc --password=abc | gzip > backup.sql.gz
To execute on the other servers, without uncompressing, use the following command:
zcat backup.sql.gz | mysql --user=abc --password=abc
If you are having this issue you can fix it my adding the --single-transaction argument to your mysqldump call.
showing a way to dump mysql databases directly into gzip and then into ssh connection, thus creating a gzipped dump archive that never resided on the server hard drive. This can be a handy way to ensure that backup does not fill up the server hard drive.
So the lock doesn't need to be acquired manually.
To overcome the replication delay, caused by restoring the dump table on the master, there is a need to widespread the massive inserts. This can be done by the MySQL SLEEP command.
See http://www.mysqldiary.com/as-restoring-a-dump-table-into-the-mysql-master-you-better-get-some-sleep/
1.run "MySQLInstanceConfig.exe".
2.Select "Create An Anonymous Account" at "Please set the security options".
His suggestion of editing the dumpfile will work, but not trying to do another CHANGE MASTER to set the host, user etc after importing the dump. That will only work if you put in the filename and log co-ordinates again, as I found to my cost.
It won't tell you what's wrong either!
Every execution of CHANGE MASTER blows off the co-ords, as it assumes you are changing to a new master.
I think you can set the user, etc before importing and it should work.