MySQL mysqldump提取没有表结构的数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12122772/
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
mysqldump extracting data without table structure
提问by judda
I'm trying to dump all of my mysql data for one database into a single file. That said, I don't want to include the table structures in this file (there is another file which will have the structure of the tables in it).
我正在尝试将一个数据库的所有 mysql 数据转储到一个文件中。也就是说,我不想在这个文件中包含表结构(还有另一个文件,其中包含表的结构)。
Is it possible to strictly extract the data and not the table structures?
是否可以严格提取数据而不是表结构?
What I am doing right now ...
我现在在做什么...
# Extracts the database structure
mysqldump -d -hlocalhost -uusername -ppassword database -r database.sql
# Extracts each table and their data individually
mysqldump -d -hlocalhost -uusername -ppassword database --tab .
The first command will spit out a .sql file with the structure of all entities in the database whereas the second one automatically makes the .sql and .txt files with the structure and entities split out.
第一个命令将吐出一个 .sql 文件,其中包含数据库中所有实体的结构,而第二个命令会自动生成具有结构和实体的 .sql 和 .txt 文件。
What I need is one copy of the entire database which is done the same way.
我需要的是整个数据库的一个副本,它以相同的方式完成。
Thanks
谢谢
回答by eggyal
Use the --no-create-info
option, or its shorthand -t
:
使用该--no-create-info
选项或其简写-t
:
--no-create-info
,-t
Do not write
CREATE TABLE
statements that re-create each dumped table.Note
This option does not notexclude statements creating log file groups or tablespaces from
mysqldump
output; however, you can use the--no-tablespaces
option for this purpose.
--no-create-info
,-t
不要编写
CREATE TABLE
重新创建每个转储表的语句。笔记
此选项不会不排除语句从创建日志文件组或者表
mysqldump
输出; 但是,您可以--no-tablespaces
为此目的使用该选项。