mysqldump data only

MysqlMysqldump

Mysql Problem Overview


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

Mysql Solutions


Solution 1 - Mysql

mysqldump --no-create-info ...

Also you may use:

  • --skip-triggers: if you are using triggers
  • --no-create-db: if you are using --databases ... option
  • --compact: if you want to get rid of extra comments

Solution 2 - Mysql

This should work:

# 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

NOTE: there's no space between -p & [pass]

Solution 3 - Mysql

If you just want the INSERT queries, use the following:

mysqldump --skip-triggers --compact --no-create-info

Solution 4 - Mysql

 >> 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

Solution 5 - Mysql

Would suggest using the following snippet. Works fine even with huge tables (otherwise you'd open dump in editor and strip unneeded stuff, right? ;)

mysqldump --no-create-info --skip-triggers --extended-insert --lock-tables --quick DB TABLE > dump.sql

At least mysql 5.x required, but who runs old stuff nowadays.. :)

Solution 6 - Mysql

Best to dump to a compressed file

mysqldump --no-create-info -u username -hhostname -p dbname | gzip > /backupsql.gz

and to restore using pv apt-get install pv to monitor progress

pv backupsql.gz | gunzip | mysql -uusername -hhostip -p dbname

Solution 7 - Mysql

Just dump the data in delimited-text format.

Solution 8 - Mysql

Try to dump to a delimited file.

mysqldump -u [username] -p -t -T/path/to/directory [database] --fields-enclosed-by=\" --fields-terminated-by=,

Solution 9 - Mysql

When attempting to export data using the accepted answer I got an error:

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'

As mentioned above:

mysqldump --no-create-info

Will export the data but it will also export the create trigger statements. If like me your outputting database structure (which also includes triggers) with one command and then using the above command to get the data you should also use '--skip-triggers'.

So if you want JUST the data:

mysqldump --no-create-info --skip-triggers

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLizardView Question on Stackoverflow
Solution 1 - MysqlmateiView Answer on Stackoverflow
Solution 2 - MysqlIshView Answer on Stackoverflow
Solution 3 - MysqlJonathanView Answer on Stackoverflow
Solution 4 - MysqlAngelin NadarView Answer on Stackoverflow
Solution 5 - MysqlwuzerView Answer on Stackoverflow
Solution 6 - MysqlmikoopView Answer on Stackoverflow
Solution 7 - MysqlFrank HeikensView Answer on Stackoverflow
Solution 8 - Mysqled209View Answer on Stackoverflow
Solution 9 - MysqlBen WaineView Answer on Stackoverflow