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

[php toolbar=”false” classname=”one_line”] C:\>cd C:\wamp\bin\mysql\mysql5.0.51b\bin
[/php]

2. Then use this command to fire up MySQL

[php toolbar=”false” classname=”one_line”] C:\wamp\bin\mysql\mysql5.0.51b\bin>mysql.exe -use databasename -u username -p
[/php]

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:

[php toolbar=”false” classname=”one_line”] mysql> source myfilename.sql;
[/php]

Note:

[php toolbar=”false” classname=”one_line”] C:\wamp\bin\mysql\mysql5.0.51b\bin>mysql.exe -use your databasename -u root
[/php]

Leave A Comment