How do I import an SQL file to MySQL dump using command line. I am using windows.
5 Answers
Navigate to the directory where you have mysql and issue this command, changing the bold values to your file/database locations.
c:\mysql\bin\> mysql -u USERNAME -p PASSWORD database_name < filename.sql
-
4I'm not sure about Windows, but under *nix, there shouldn't be any space between
-p
and the password.– cedbeuCommented Aug 6, 2013 at 15:44 -
1with windows -p password loads the my.inf file. removing the space works. Commented Sep 6, 2013 at 17:16
-
this works fine with windows mysql -u USERNAME -p database_name < filename.sql. After this command you may have to enter your password.– VivekCommented Dec 16, 2013 at 6:07
Simple steps to import sql file.
Click on WampServer and then go to MySQL=> MySQL console enter password \If no password click simply enter create database database_name; \If database already there skip this step use database_name; source D:\backup.sql \Path of database file
Try like this:
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
Refer this link also:
Try this
C:\Program Files\Mysql\Mysql server 5.6\bin\mysql -u {username} -p {password} {your database name} < file-name.sql
Note here file-name.sql is in mysql server 5.6\bin
To dump all databases, use the -all-databases
option. With that option, no database needs to be specified.
mysqldump -u username -ppassword –all-databases > dump.sql
-
2