Tuesday, October 22, 2013

Import MySql DB through command prompt on WAMP

Hello,

If we have a very large file to import on WAMP and PHPMyAdmin is dying due to various reasons then you can import the big file using CLI or through Dos

Follow the following steps.
  1. Run cmd command
  2. Assuming you have installed wamp on C: drive.
  3. C:>cd wamp
  4. C:\wamp>cd bin
  5. C:\wamp\bin>cd mysql
  6. C:\wamp\bin\mysql>cd mysql15.5.8
  7. C:\wamp\bin\mysql\mysql15.5.8>cd bin
  8. C:\wamp\bin\mysql\mysql15.5.8\bin>mysql.exe -u root -p dbname < sqlDump.sql
  9. Now we need to have the sqlDump.sql file inside C:\wamp\bin\mysql\mysql15.5.8\bin\ for direct execution of this command.
  10. If everything is fine, then this command will ask for the mysql password for username root and it should start importing the file on the mysql database.

Now what we are doing here is we are moving to WAMP's bin directory to locate the mysql.exe file. This command file is similar to the one we have on Linux and it behave s the same way, so we provide the information like username db and import sql file and it can easily be imported in our db.

Please note: We can also use direct path from any location as soon as we come to cmd like C:\wamp\bin\mysql\mysql15.5.8\bin\mysql.exe -u root dbname < sqlDump.sql
but need to be sure of the path which is hard to locate.

Thanx
Anshumaan Bakshi

No comments:

Post a Comment