DEVOPS
DEVOPS

Reputation: 18790

How to import an SQL file by using mysqldump on Windows through command line

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

Upvotes: 12

Views: 37792

Answers (5)

jas jashim
jas jashim

Reputation: 196

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

Upvotes: 0

Baskaran
Baskaran

Reputation: 101

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

Upvotes: 1

Xman Classical
Xman Classical

Reputation: 5406

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/

Upvotes: 0

Noor Khan
Noor Khan

Reputation: 520

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

Upvotes: -2

ayush
ayush

Reputation: 14568

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

Upvotes: 21

Related Questions