How do I split a large MySql backup file into multiple files?
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?
It seems like people are answering the wrong question ... so I will clarify more:
I ONLY have the 250 MB file and only have the new hosting using phpMyAdmin which currently has no data in the database. I need to take the 250 MB file and upload it to the new host but there is a 100 MB SQL backup file upload size limit. I simply need to take one file that is too large and split it out into multiple files each containing only full valid SQL statements (no statements can be split between two files).
Solution 1:
From How do I split the output from mysqldump into smaller files?
First dump the schema (it surely fits in 2Mb, no?)
mysqldump -d --all-databases
and restore it.
Afterwards dump only the data in separate insert statements, so you can split the files and restore them without having to concatenate them on the remote server
mysqldump --all-databases --extended-insert=FALSE --no-create-info=TRUE
Solution 2:
Simplest way to split the backup file is to use a software sqldumpsplitter
, which allows you to split the db file into multiple db files. Download here
Or else use this terminal command.
split -l 600 ./path/to/source/file.sql ./path/to/dest/file-
Here, 600 is the number of lines you wish to have in your split files. And the two arguments are source and the destination of the files respectively.
NOTE: you must check the split files, you don't split any command.
Solution 3:
I wrote mysqldumpsplitter (shell script), which splits the databases/tables as instructed in a quick and easy way. See all the possible use cases of how-to extract from mysqldump.
sh mysqldumpsplitter.sh --source mysqldump-file.sql --extract DB --match_str database-name