How to Import SQL File Within WAMP Environment Using Command Line

This is something I've done already so many times, but just because I don't do it every month, I forget it all the time. So, I thought I would make a reminder note to myself and anyone else who has similar problem :)

The easiest way for me to import an sql file into a database in WAMP environment using command line is using follwoing:

1. Run the cmd (DOS) and get into the mysql folder, which in my case works like this

C:\>cd C:\wamp\bin\mysql\mysql5.0.51b\bin

2. Then use this command to fire up MySQL

C:\wamp\bin\mysql\mysql5.0.51b\bin>mysql.exe -use databasename -u username -p password_optional_if_you_have_one

This line basically connects you to the mysql database of your choice.
3. To make things easier, I copy my SQL file into the same folder where the mysql.exe file is located. And then run this

mysql> source myfilename.sql;

That's it folks!

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.