我正在寻找在我的mysql数据库转储所有数据的语法。我不需要任何表信息。
当前回答
>> man -k mysqldump [enter in the terminal]
下面的解释如下
--no-create-info, -t Do not write CREATE TABLE statements that re-create each dumped table. Note This option does not not exclude statements creating log file groups or tablespaces from mysqldump output; however, you can use the --no-tablespaces option for this purpose. --no-data, -d Do not write any table row information (that is, do not dump table contents). This is useful if you want to dump only the CREATE TABLE statement for the table (for example, to create an empty copy of the table by loading the dump file).
# To export to file (data only)
mysqldump -t -u [user] -p[pass] -t mydb > mydb_data.sql
# To export to file (structure only)
mysqldump -d -u [user] -p[pass] -d mydb > mydb_structure.sql
其他回答
这应该可以工作:
# To export to file (data only)
mysqldump -u [user] -p[pass] --no-create-info mydb > mydb.sql
# To export to file (structure only)
mysqldump -u [user] -p[pass] --no-data mydb > mydb.sql
# To import to database
mysql -u [user] -p[pass] mydb < mydb.sql
注意:在-p和[pass]之间没有空格
mysqldump --no-create-info ...
你还可以用:
——跳过触发器:如果你正在使用触发器 ——no-create-db:如果你正在使用——databases…选项 ——compact:如果你想去掉额外的注释
如果你只想要INSERT查询,使用下面的方法:
Mysqldump—skip-triggers—compact—no-create-info
建议使用下面的代码片段。即使是巨大的表也能正常工作(否则你会在编辑器中打开转储并删除不需要的东西,对吗?;)
mysqldump --no-create-info --skip-triggers --extended-insert --lock-tables --quick DB TABLE > dump.sql
至少mysql 5。要求X,但现在谁经营这些老东西。:)
尝试转储到一个带分隔符的文件。
mysqldump -u [username] -p -t -T/path/to/directory [database] --fields-enclosed-by=\" --fields-terminated-by=,