Daniel Nill Daniel Nill - 1 year ago 114
MySQL Question

How do you use MySQL's source command to import large files in windows

I have a large (~150mb) sql file that I am trying to import. It is too large to do it through PHPMyAdmin even splitting it into many pieces and it is too large to import through a php script as it times out after 30 seconds of processing the script. So I'm looking for how to directly import the file from MySQL command line.

Searching online shows that I want to either use

database_name < file_name.sql
source file_name.sql
but I can't get either of these to work.

gives the generic MySQL syntax error while using
give a slightly more promising
failed to open file 'file_name.sql', error: 2
so I am inclined to think that the source command is on the right track.

I am in windows and am using xampp as a localhost server (note I'm only trying to import this file on the localhost so that I can execute the sql). I've tried placing the file in

Any suggestions of how to import this .sql file into MySQL either from the MySQL command line or by any other means would be greatly appreciated.

Answer Source

With xampp I think you need to use the full path at the command line, something like this, perhaps:

C:\xampp\mysql\bin\mysql -u {username} -p {databasename} < file_name.sql
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download