dump all mysql tables into separate files automagically?

后端 未结 10 935
北恋
北恋 2020-11-29 20:21

I\'d like to get dumps of each mysql table into separate files. The manual indicates that the syntax for this is

mysqldump [options] db_name [tbl_name ...]
         


        
10条回答
  •  [愿得一人]
    2020-11-29 21:05

    The mysqldump command line program does this for you - although the docs are very unclear about this.

    One thing to note is that ~/output/dir has to be writable by the user that owns mysqld. On Mac OS X:

    sudo chown -R _mysqld:_mysqld ~/output/dir
    mysqldump --user=dbuser --password --tab=~/output/dir dbname
    

    After running the above, you will have one tablename.sql file containing each table's schema (create table statement) and tablename.txt file containing the data.

    If you want a dump with schema only, add the --no-data flag:

    mysqldump --user=dbuser --password --no-data --tab=~/output/dir dbname
    

提交回复
热议问题