Dumping views with mysqldump in the right order.
Posted
by Bushibytes
on Stack Overflow
See other posts from Stack Overflow
or by Bushibytes
Published on 2010-03-19T18:06:50Z
Indexed on
2010/03/19
19:51 UTC
Read the original article
Hit count: 585
I have a script that backs up our database, which contains multiple tables and views constructed from tables.
The command used is: mysqldump -u UserName -ppassword -h hostname DatabaseName > dump.sql;
I have noticed however that some view definitions are backed up before the definitions of the tables. This causes an issue when restoring using the classic
mysql -u UserName -p < dump.sql
As when it tries to create the view, the table it needs does not exist yet. It is possible to edit the dump files to be restored, but I was wondering:
Is there a way to either make sure that mysqldump backs up the tables and views in the right order? Or is there a way to restore from a dump that will find the right tables to create first (or create sane temporary tables)?
Edit for version: mysqldump Ver 10.11 Distrib 5.0.51b, for redhat-linux-gnu (x86_64)
© Stack Overflow or respective owner