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
or source file_name.sql
but I can't get either of these to work.
Using <
gives the generic MySQL syntax error while using source
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 xampp\mysql\bin
and xampp\mysql\data\database_name
.
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.
Ok you use PHPMyAdmin but sometimes the best way is through terminal: Connect to database: mysql -h localhost -u root -p (switch root and localhost for user and database location) Start import from dump: \. /path/to/your/file. sql.
SQL Data Source mode provides the commands to create or modify an SQL data source configuration. To enter the mode, use the Global sql-source command. To delete an SQL data source, use the Global no sql-source command.
On Windows this should work (note the forwardslash and that the whole path is not quoted and that spaces are allowed)
USE yourdb;
SOURCE D:/My Folder with spaces/Folder/filetoimport.sql;
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With