我正在寻找在我的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
其他回答
只需将数据转储为带分隔符的文本格式。
当试图使用接受的答案导出数据时,我得到了一个错误:
ERROR 1235 (42000) at line 3367: This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'
如上所述:
mysqldump --no-create-info
将导出数据,但它也将导出create触发器语句。如果你像我一样用一个命令输出数据库结构(也包括触发器),然后使用上面的命令来获取数据,你也应该使用'——skip-triggers'。
所以如果你只想要数据:
mysqldump --no-create-info --skip-triggers
最好转储到一个压缩文件
mysqldump --no-create-info -u username -hhostname -p dbname | gzip > /backupsql.gz
并使用pv apt-get安装pv来监控进度
pv backupsql.gz | gunzip | mysql -uusername -hhostip -p dbname
如果你只想要INSERT查询,使用下面的方法:
Mysqldump—skip-triggers—compact—no-create-info
mysqldump --no-create-info ...
你还可以用:
——跳过触发器:如果你正在使用触发器 ——no-create-db:如果你正在使用——databases…选项 ——compact:如果你想去掉额外的注释