DSB/MySQLDumper

Backup: Set database name

Vanmaele opened this issue · 5 comments

I created a backup file of my database, successfully. After i tried to import the generated sql file in phpMyAdmin. I get an error because the file does not set the database name.

I got it to work by modifying the "functions_dump.php". I have added "$statuszeile.="USE {$databases['Name'][$dump['dbindex']]};".$nl;".

Is this a good modification or is there another method?

A sql dump doesn't include a database create action or use action by default. It includes the table structure and data of a database in form of sql statements in order to backup data from a database and restore the data by committing the sql statements.

MySQLDumper and mysqldump itself except that there is an existing database specified to import the dump. phpMyAdmin provides both the option to import a file when no database is selected and when a database is selected.

If MySQLDumper would add create and use actions at the beginning of every dump there would be no possibility to import the file into a different named database any more without editing the dump file. This would be very unusable in my opinion.

Of course there would be the possibility to add another check box before creating the dump so that the user can decide weather MySQLDumper writes the create/use statement in the dump.

bildschirmfoto vom 2016-08-21 14-35-37

Thank you for the clear explanation. I suppose the extra option isn't that usefull when you have the option in phpMyAdmin (which I didn't knew).

DSB commented

But: since MySQLDumper ignores USE statements in SQL files because of the above mentioned reason, it wouldn't hurt if it would be placed in the backup. I'm not sure if this is also true for CREATE DATABASE statements. But this could be added if necessary.
I just don't understand why one uses MySQLDumper for creating the backup and would then want to use PhpMyAdmin to import it. Inserting data takes much longer and so the danger that a timeout happens here is much higher. So I - of course - would use MySQLDumper to import the backup because I know it handles that much better.

@DSB I had to figure out how to make a solid DB backup without one logging into the hosting server. By using MySQLDumper it is possible to get this backup file. The file is downloaded and placed together with the web files in zip file, which serves as a full backup package of the website. And of course, to be sure the backup file was working I had to try it out in myPhpAdmin...

Besides I also like the tool for updating the DB on localhost side.

DSB commented

So after all I can close this "issue"?