12

How do I import an SQL file to MySQL dump using command line. I am using windows.

5 Answers 5

21

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
3
  • 4
    I'm not sure about Windows, but under *nix, there shouldn't be any space between -p and the password.
    – cedbeu
    Commented Aug 6, 2013 at 15:44
  • 1
    with 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.
    – Vivek
    Commented Dec 16, 2013 at 6:07
1

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

0

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:

http://www.ryantetek.com/2011/09/importing-large-sql-files-through-command-line-when-using-phpmyadminxampp/

0

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

-1

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
1
  • 2
    This is to EXPORT, not to IMPORT.
    – PJunior
    Commented Mar 9, 2017 at 0:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.