Mysql – Will a thesqldump ever break the database

MySQLmysqldump

I tried to backup my database with mysqldump. I've done this on a live website also. Is there any chance that this command could ever break a website/database?

Best Answer

The mysqldump utility will not break your database.

Read the source code for it and/or turn on the general query log while it's running and you'll see that what all it does it look.

But...

If you are using MyISAM, or if you fail to use the --single-transaction option, or you issue a FLUSH TABLES; request from another connection while the backup is reading a large table, you stand a higher chance of stalling your web site because there are things that can happen to cause queries to block until the specific table or the entire backup is complete.

And, if you do have serious corruption in your data, mysqldump stands a good chance of running into it, since it reads every row from every table by default, which means the server will be trying to read through the corruption and could crash. This is essentially true of any backup, of course.

But directly and ordinarily and by most reasonable definitions, mysqldump cannot harm your database contents.