Adam Scot
Adam Scot

Reputation: 1409

Upload mysql database in chunks

I am trying to upload a 32mb MYSQL database into a pre-existing database, but the php admin on my shared hosting has a 10mb limit... I have tried zipping it up - but when the server unzips the database, the uncompressed file is too large for the server to handle.

Is it possible to split the database up and upload it by pasting it in parts as an SQL query - I assume I would need each chunk to have something at the start of it which says

"Import this data into the pre-existing tables in the database"

What would this be?

At the moment there is a few hundred lines saying things like "CREATE" and "INSERT INTO"

Upvotes: 0

Views: 877

Answers (2)

Kevin Seifert
Kevin Seifert

Reputation: 3572

You might try connecting to the database remotely with mysql workbench, or command line tool mysql. If you can do that, you can run:

source c:/path/to/your/file.sql

and you won't be constrained by phpmyadmin's upload size restrictions. Most shared hosting I've seen allows it. If not, you may just need to grant permissions for the user@host in phpmyadmin (or whatever the interface is).

Upvotes: 2

James C
James C

Reputation: 14149

The dump file created by mysqldump is just a set of SQL statements that will rebuild your tables.

To load it in in chunks I'd recommend either dumping it out in sets of tables and loading them one by one or if required the dump file should be roughly in the same (pseudo) format:

Set things up ready for loading

CREATE TABLE t1;
INSERT INTO TABLE t1...;
INSERT INTO TABLE t1...;

CREATE TABLE t2;
INSERT INTO TABLE t2...;
INSERT INTO TABLE t2...;

Finalise stuff after loading

You can manually split the file up by keeping the commands at the start and finish and just choosing blocks for individual tables by looking for their CREATE TABLE statements.

Upvotes: 0

Related Questions