2

I've got a quite huge (> 8mo) sql file that basically creates 2 tables and populate them with data. It's a dump generated from Sequel Pro. My first idea was to read the file line by line and run an "execute" command, but I've got an error that my string was too big.

Mysql2::Error: Got a packet bigger than 'max_allowed_packet' bytes

Is there any way to run directly the SQL file instead of reading it and try to execute ?
FYI I can split this file in 2 parts for the 2 tables, but I'll have an other one a lot bigger after and that can't be splited.
I'm using Rails 3.0.3 with ActiveRecord and a MySQL Database.

  • Isn't it the same case as here? ;) http://stackoverflow.com/questions/93128/mysql-got-a-packet-bigger-than-max-allowed-packet-bytes – santuxus Mar 18 '11 at 09:00

1 Answers1

5

Is it a proper SQL file (with SQL statements in it) ?

If so, you should be able to do this on the command line:

mysql target-db-name < sql-file-name.sql -uuser -p

Hit return, it'll prompt you for password and you're off

Remember to substitute in proper values for target-db-name, sql-file-name.sql and user

Note: target-db-name should be created beforehand: I don't think it will auto-create

TerryS
  • 7,169
  • 1
  • 17
  • 13