【mydqldump】
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: