I'm using phpMyAdmin 4.0.2 and seems when doing an export over a whole DB, by default it adds the statement "CREATE DATABASE IF NOT EXISTS" in the beginning of the export SQL.
我正在使用phpMyAdmin 4.0.2并且似乎在对整个数据库进行导出时,默认情况下它会在导出SQL的开头添加语句“CREATE DATABASE IF NOT EXISTS”。
I wasn't able to find a config option or any option to disable that... So is there a way to disable that and not have that statement in my exports by default?
我无法找到配置选项或任何禁用该选项的选项...那么有没有办法禁用它,默认情况下我的导出中没有该语句?
2 个解决方案
#1
2
This behavior did not happen by default in version 3. A quick fix, actually a hack and thus not the desirable solution, is to edit the export class file located in libraries/plugins/export/ExportSql.class.php and force the CREATE and USE statements to be commented out by adding "-- " before them, as such: Line 709
在版本3中默认情况下不会发生此行为。快速修复,实际上是一个黑客,因此不是理想的解决方案,是编辑位于libraries / plugins / export / ExportSql.class.php中的导出类文件并强制创建和通过在它们之前添加“ - ”来注释USE语句,如下所示:第709行
$create_query = '-- CREATE DATABASE IF NOT EXISTS '
Line 734
'-- USE ' . PMA_Util::backquoteCompat($db, $compat)
Edit: There's a drawback, and that is if you export one or more entire databases (not just some or all the tables inside a database), then the CREATE and USE statements appear commented also.
编辑:有一个缺点,那就是如果您导出一个或多个整个数据库(不仅仅是数据库中的部分或全部表),那么CREATE和USE语句也会出现注释。
#2
0
A better idea as opposed to Hermes's answer would be to edit the file ./export.php
( Mind you: not db_export.php
).
与Hermes的答案相反,更好的想法是编辑文件./export.php(注意:不是db_export.php)。
On line 724 ( in phpMyAdmin 4.0.4 ) you'll find the lines:
在第724行(在phpMyAdmin 4.0.4中),您将找到以下行:
if (! $export_plugin->exportDBCreate($db)) {
break;
}
You can comment or remove them to skip the creation of the create database statements ( Which in my opinion is also neater then having 2 commented lines in the export ).
您可以注释或删除它们以跳过创建数据库语句(在我看来,它也更简洁,然后在导出中有2条注释行)。
Like so:
/*
if (! $export_plugin->exportDBCreate($db)) {
break;
}
*/
The rows above only apply to exporting a single database ( On line 720, you'll find: } elseif ($export_type == 'database') {
). So you won't break full server exports.
上面的行仅适用于导出单个数据库(在第720行,您将找到:} elseif($ export_type =='database'){)。因此,您不会破坏完整的服务器导出。
#1
2
This behavior did not happen by default in version 3. A quick fix, actually a hack and thus not the desirable solution, is to edit the export class file located in libraries/plugins/export/ExportSql.class.php and force the CREATE and USE statements to be commented out by adding "-- " before them, as such: Line 709
在版本3中默认情况下不会发生此行为。快速修复,实际上是一个黑客,因此不是理想的解决方案,是编辑位于libraries / plugins / export / ExportSql.class.php中的导出类文件并强制创建和通过在它们之前添加“ - ”来注释USE语句,如下所示:第709行
$create_query = '-- CREATE DATABASE IF NOT EXISTS '
Line 734
'-- USE ' . PMA_Util::backquoteCompat($db, $compat)
Edit: There's a drawback, and that is if you export one or more entire databases (not just some or all the tables inside a database), then the CREATE and USE statements appear commented also.
编辑:有一个缺点,那就是如果您导出一个或多个整个数据库(不仅仅是数据库中的部分或全部表),那么CREATE和USE语句也会出现注释。
#2
0
A better idea as opposed to Hermes's answer would be to edit the file ./export.php
( Mind you: not db_export.php
).
与Hermes的答案相反,更好的想法是编辑文件./export.php(注意:不是db_export.php)。
On line 724 ( in phpMyAdmin 4.0.4 ) you'll find the lines:
在第724行(在phpMyAdmin 4.0.4中),您将找到以下行:
if (! $export_plugin->exportDBCreate($db)) {
break;
}
You can comment or remove them to skip the creation of the create database statements ( Which in my opinion is also neater then having 2 commented lines in the export ).
您可以注释或删除它们以跳过创建数据库语句(在我看来,它也更简洁,然后在导出中有2条注释行)。
Like so:
/*
if (! $export_plugin->exportDBCreate($db)) {
break;
}
*/
The rows above only apply to exporting a single database ( On line 720, you'll find: } elseif ($export_type == 'database') {
). So you won't break full server exports.
上面的行仅适用于导出单个数据库(在第720行,您将找到:} elseif($ export_type =='database'){)。因此,您不会破坏完整的服务器导出。