How to remove the CREATE DATABASE IF NOT EXISTS statement from Export in phpMyAdmin 4?

I use phpMyAdmin 4.0.2 and it seems that when I export to the whole database, by default it adds the "CREATE DATABASE IF NOT EXISTS" statement at the beginning of the SQL export.

I was not able to find a configuration option or any option to disable this ... So is there a way to disable this and not have this statement in my default export?

+7
source share
2 answers

This behavior did not happen by default in version 3. A quick fix, actually a hack, and therefore not a desirable solution, is to edit the export class file located in the libraries / plugins / export / ExportSql.class.php and force the CREATE statements and USE should be commented by adding a “-” in front of them: Line 709

$create_query = '-- CREATE DATABASE IF NOT EXISTS ' 

Line 734

 '-- USE ' . PMA_Util::backquoteCompat($db, $compat) 

Edit: There is a flaw, and if you export one or more whole databases (and not just some or all of the tables inside the database), CREATE and USE comments are also displayed.

+2
source

A better idea, unlike Hermes' answer, would be to edit the ./export.php file (Mind you: not db_export.php ).

On line 724 (in phpMyAdmin 4.0.4) you will find the lines:

  if (! $export_plugin->exportDBCreate($db)) { break; } 

You can comment or delete them to skip the creation of database creation statements (which, in my opinion, are also more accurate than the two selected lines in the export).

Same:

  /* if (! $export_plugin->exportDBCreate($db)) { break; } */ 

The above lines apply only to exporting one database (on line 720 you will find: } elseif ($export_type == 'database') { ). Thus, you will not interrupt the full export of servers.

0
source

All Articles