Thursday, 8 November 2018

Mysql: mysqldump data only

I am looking for the syntax for dumping all data in my mysql database. I don't want any table information.

 Answers


mysqldump --no-create-info ...
If you are using triggers you also need to include --skip-triggers
And if you are using the --databases ... option you also need to include --no-create-db



 >> man -k  mysqldump [enter in the terminal]
you will find the below explanation
--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



If you just want the INSERT queries, use the following:
mysqldump --skip-triggers --compact --no-create-info



Try to dump to a delimited file.
mysqldump -u [username] -p -t -T/path/to/directory [database] --fields-enclosed-by=\" --fields-terminated-by=,

0 comments:

Post a Comment