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
Sign up to request clarification or add additional context in comments.

3 Comments

I'm not sure about Windows, but under *nix, there shouldn't be any space between -p and the password.
with windows -p password loads the my.inf file. removing the space works.
this works fine with windows mysql -u USERNAME -p database_name < filename.sql. After this command you may have to enter your password.
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

Comments

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/

Comments

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

Comments

-2

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 Comment

This is to EXPORT, not to IMPORT.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.