如何将 MySQL 数据库转换为 XML?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1420205/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:05:54  来源:igfitidea点击:

How to convert a MySQL DB to XML?

mysqlxml

提问by Svetlozar Angelov

How can you convert a MySQL database to XML? I want everythimg... data and there relation in XML schema file

如何将 MySQL 数据库转换为 XML?我想要所有的...数据和 XML 模式文件中的关系

how to convert from sqlyog community 8.13(free version)

如何从sqlyog社区8.13(免费版)转换

回答by Svetlozar Angelov

mysqldump --xml test > test.xml

or

或者

mysqldump -X test > test.xml

mysqldump to xml

mysqldump 到 xml

回答by nickf

phpMyAdminhas an Export to XML function in it. You could either use that, or examine the code to see how they did it.

phpMyAdmin 中有一个导出到 XML 的功能。您可以使用它,也可以检查代码以了解它们是如何做到的。

回答by Alterlife

The command line client that comes with MySQL has a --xml option: http://dev.mysql.com/doc/refman/5.1/en/mysql-command-options.html#option_mysql_xml

MySQL 自带的命令行客户端有一个 --xml 选项:http: //dev.mysql.com/doc/refman/5.1/en/mysql-command-options.html#option_mysql_xml

If the output format of that does not match what you need, you could just select the data out and concatenate it with your xml tags:

如果它的输出格式与您需要的不匹配,您只需选择数据并将其与您的 xml 标签连接起来:

select concat('<field1>',field1,'</field1><field2>',field2,
'</field2>') from table

回答by Kamal Micheal

For a single table

对于单个表

mysql --xml -u username -p database_name table_name > table_name.xml

For a query

查询

mysql --xml -u username -p database_name -e 'select * from table_name' > query.xml

For the whole database

对于整个数据库

mysqldump --xml -u username -p database_name > database.xml

回答by Rippo

SQLyog also does a good implementation of exporting data to XML...

SQLyog 也很好地实现了将数据导出到 XML...