Export a large MySQL table as multiple smaller files

前端 未结 7 1289
你的背包
你的背包 2020-12-28 09:26

I have a very large MySQL table on my local dev server: over 8 million rows of data. I loaded the table successfully using LOAD DATA INFILE.

I now wish to export thi

7条回答
  •  一生所求
    2020-12-28 09:59

    I just did an import/export of a (partitioned) table with 50 millions record, it needed just 2 minutes to export it from a reasonably fast machine and 15 minutes to import it on my slower desktop. There was no need to split the file.

    mysqldump is your friend, and knowing that you have a lot of data it's better to compress it

     @host1:~ $ mysqldump -u  -p   | gzip > output.sql.gz
     @host1:~ $ scp output.sql.gz host2:~/
     @host1:~ $ rm output.sql.gz
     @host1:~ $ ssh host2
     @host2:~ $ gunzip < output.sql.gz | mysql -u  -p 
     @host2:~ $ rm output.sql.gz
    
        

    提交回复
    热议问题