MySQL Replication – Is it Safe to Lock Tables on a MySQL Replica Slave?

MySQLmysql-replication

I have a master mysql database where the application writes and read production data, and then I setup a slave database just in case something goes wrong with the master database server (and I can do a quick switch).

On the slave database, I run reports.

I have to create daily backups for the database, I was thinking on creating them on the slave database, so the production environment can continue working without any delay, and now I have the option to lock or not the slave tables.

Is it safe to lock the tables to perform the backup (which could take like 30 minutes) and once the backup is done, mysql does automatically sync the slave database with the updates performed on the master database when the tables were locked?

Best Answer

Thats fine. The slave tables can be locked, and it will catch up the master later on (as long as the bin log is not expired, normally its set for couple of days)