Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 221
Or Weinberger Avatar asked Sep 03 '25 14:09

Or Weinberger


2 Answers

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

like image 189
Or Weinberger Avatar answered Sep 05 '25 05:09

Or Weinberger


Does this work from the console?

mysql -u username -ppassword databasename < file.sql

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

like image 26
WWW Avatar answered Sep 05 '25 03:09

WWW