mysqldump data only

前端 未结 9 851
傲寒
傲寒 2020-12-02 03:55

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

相关标签:
9条回答
  • 2020-12-02 04:33

    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
    
    
    0 讨论(0)
  • 2020-12-02 04:40
    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
    0 讨论(0)
  • 2020-12-02 04:49

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

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

    0 讨论(0)
  • 2020-12-02 04:50

    Just dump the data in delimited-text format.

    0 讨论(0)
  • 2020-12-02 04:50

    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
    
    0 讨论(0)
  • 2020-12-02 04:56

    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]

    0 讨论(0)
提交回复
热议问题