How do you use MySQL's source command to import large files in windows
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
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;
Don't use "source"
, it's designed to run a small number of sql queries
and display the output, not to import large databases.
I use Wamp Developer
(not XAMPP
) but it should be the same.
What you want to do is use the MySQL Client
to do the work for you.
- Make sure
MySQL
is running. - Create your database via
phpMyAdmin
or theMySQL shell
. - Then, run
cmd.exe
, and change to the directory yoursql
file is located in. - Execute:
mysql -u root -p database_name_here < dump_file_name_here.sql
- Substitute in your
database name
anddump file name
. - Enter your
MySQL root account password
when prompted (if no password set, remove the "-p" switch).
This assumes that mysql.exe
can be located via the environmental path, and that sql
file is located in the directory you are running this from. Otherwise, use full paths.