开发者

How do I split a large MySQL backup file into multiple files? [duplicate]

This question already has answers here: How do I split the output from mysqldump into smaller files? (17 answers) 开发者_StackOverflow中文版 Closed 6 years ago.

I have a 250 MB backup SQL file but the limit on the new hosting is only 100 MB...

Is there a program that let's you split an SQL file into multiple SQL files?


You can split a large file in Eclipse. I have tried a 105GB file in Windows successfully:

Just add the MySQLDumpSplitter library to your project: http://dl.bintray.com/verace/MySQLDumpSplitter/jar/

Quick note on how to import:

  • In Eclipse, Right click on your project --> Import
  • Select File System and then Next
  • Browse the path of the jar file and press Ok
  • Select (thick) the MySQLDumpSplitter.jar file and then Finish
  • It will be added to your project and shown in the project folder in Package Explorer in Eclipse
  • Double click on the jar file in Eclipse (in Package Explorer)
  • The MySQL Dump file splitter window opens which you can specify the address of your dump file and proceed with split.


It's not pretty (because it just splits on size, not on what is logically in the file) but you can use the unix split tool to accomplish this:

mysqldump mydb | split -b 100m mydbbackup

Make sure to check the man page for split, your copy may or may not accept the 100m size argument. Some need to have the size specified in bytes.

When you go to restore from the file you'll have to use cat to join them all back together.

cat mydbbackup.1 mydbbackup.2 mydbbackup.3 | mysql


You can use mysql_export_explode https://github.com/barinascode/mysql-export-explode

<?php 
#Including the class

include 'mysql_export_explode.php';
$export = new mysql_export_explode;

$export->db = 'dataBaseName'; # -- Set your database name
$export->connect('host','user','password'); # -- Connecting to database
$export->rows = array('Id','firstName','Telephone','Address'); # -- Set which fields you want to export
$export->exportTable('myTableName',15); # -- Table name and in few fractions you want to split the table
?>

At the end of the SQL files are created in the directory where the script is executed in the following format
---------------------------------------
myTableName_0.sql
myTableName_1.sql
myTableName_2.sql
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜