没有数据库名称的mysqldump [英] mysqldump without database name

查看:54
本文介绍了没有数据库名称的mysqldump的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在输出中没有数据库名称的情况下以 xml 格式转储数据?

Is it possible to dump data in xml format without the database name in the output?

如果我使用 --xml 选项转储这样的输出:

If I dump output like this with the --xml option:

$>mysqldump --xml my_database_name my_table > my_table.xml

然后我的输出类似于

<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="my_database_name">
...

您可以在输出中看到我不想要的数据库名称.

You can see the database name in the output which I do not want.

有没有办法阻止这种情况发生?

Is there an option to prevent that?

推荐答案

我认为 mysqldump 命令没有这样的选项.生成 XML 文件后,您始终可以使用脚本从转储文件中删除数据库标记.在 Windows 的 PowerShell 中,您始终可以使用以下命令:

I don't think there is such option for the mysqldump command. After generating the XML file, you can always use a script to get rid off the database tags from the dump file. In Windows' PowerShell you could always use the following command:

${c:my_table.xml} -replace "`<database name=`"my_database_name`"`>" -replace "`<\database`>" > my_table_new.xml

这篇关于没有数据库名称的mysqldump的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆