Having trouble importing a large SQL dump through phpMyAdmin? This is a problem that often plagues users of shared web hosting, when they’re moving to a new host or restoring a backup. Since most shared hosting providers don’t offer shell access, you have to use a tool like phpMyAdmin to upload and load your SQL file.
Unfortunately, phpMyAdmin often has trouble processing large files. Sometimes it takes so long for the process to run that it times out, or other times the upload quota is simply too low.
Fortunately, there’s a simple solution: split your SQL file into smaller chunks. Here’s a command you can use under Mac OS X or Linux to do it automatically:
split -l 5000 ./path/to/mysqldump.sql ./mysqldump/dbpart-
The split command takes a file and breaks it into multiple files. The -l 5000 part tells it to split the file every five thousand lines. (You can tweak this value to find a good medium between fewer files and larger sizes.) The next bit is the path to your file, and the next part is the path you want to save the output to. Files will be saved as whatever filename you specify (e.g. “dbpart-“) with an alphabetical letter combination appended.
Now you should be able to import your files one at a time through phpMyAdmin without issue.