Or Weinberger
Or Weinberger

Reputation: 7472

Importing a large SQL file

I've seen a lot of questions regarding this topic, but going through these didn't help so I'm asking..

I have a large sql file (around 50mb) which I cannot import using phpmyadmin as it's limited to 2.5mb.

I've tried to use bigdump and I'm getting an error that says that says that I'm using "extended inserts or very long procedure definitions".

I've also tried using the source command from the console, which also gives me an error message saying that the defined max_allowed_packet is too low, after changing it to 128M (was 16M before) I'm getting another issue where during the source command I'm losing the connection to the DB server (hosted locally):

ERROR 2013 (HY000): Lost connection to MySQL server during query
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
ERROR:
Can't connect to the server

Upvotes: 4

Views: 8387

Answers (4)

nightcoder
nightcoder

Reputation: 13509

In my case the problem ("Lost connection to MySQL Server during query") was in a corrupted dump file or in the misbehaving HDDs:

First, I made a dump on the main server and then copied that dump to the replication server. But it seems the replication server had some problems with its HDDs and the dump became corrupted, i.e. MD5 of the original dump file on the main server was different from MD5 of the dump copy on the replication server.

Upvotes: 1

Or Weinberger
Or Weinberger

Reputation: 7472

The solution I found to be working is to further increase the max_allowed_packet to 512M.

Then the following will work:

mysql -u username -ppassword databasename < file.sql

Upvotes: 6

TheTechGuy
TheTechGuy

Reputation: 17354

Are you exporting or importing. If you are importing try CSV format.

You can export into CSV and then import. If it still does not import because it is large CSV, then you can break the CSV yourself to make it smaller CSV files.

Upvotes: 0

WWW
WWW

Reputation: 9860

Does this work from the console?

mysql -u username -ppassword databasename < file.sql

(Yes, there is no space between the -p and password)

Upvotes: 1

Related Questions