MySQL: Difference between revisions

Jump to navigation Jump to search
495 bytes added ,  24 May 2017
Line 52: Line 52:
=== Create a snapshot using mysqldump (on master) ===
=== Create a snapshot using mysqldump (on master) ===


While the first session with <code>FLUSH TABLES</code> is still hanging there, run the following command on a different session to dump the databases. This assumes there are existing data using InnoDB engines.
While the first session with <code>FLUSH TABLES</code> is still hanging there, make a dump of the databases. This assumes there are existing data in InnoDB tables, and you are only backing up databases that have names starting with ''foobar''.  Note that you will be entering the password twice for root.


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ mysqldump --all-databases --master-data > dbdump.db
$ mysqldump --master-data --databases `mysql -B -N -e "SHOW DATABASES LIKE 'foobar%'" -uroot -p` -uroot -p
</syntaxhighlight>
 
The next command is for dumping EVERYTHING. I didn't use this, but it's put here merely as a reference. I would not use this if your master & slave are of different versions. Mine happens to be MySQL & MariaDB, so it's a big no no.
 
<syntaxhighlight lang="bash">
$ mysqldump --all-databases --master-data -uroot -p > dbdump.db
</syntaxhighlight>
</syntaxhighlight>


Navigation menu