Importing a mysql database using command prompt in WAMP

Sometimes, you get an error while importing sql file. To import the database without any hassle in WAMP for windows, we can use the following command line :

  1. Open the command line : Click Windows + r, type cmd and enter
  2.  Copy the mysql path from bin folder i.e. Copy path : D:\wamp64\bin\mysql\mysql5.7.11\bin\,  and set the same path in the command line
  3.  Run MySQL in command line i.e MySQL -u root -p
  4.  It will ask for MYSQL root password. Enter password ( if it is empty, simply press enter )
  5. To create a new database, run the following command line i.e CREATE DATABASE db_name . Replace db_name with the name of the database you want to create
  6.  To import the tables in the new or existing database, type the following in command : USE db_name;
  7.  Copy the path of the database from where you want to import the database. Enter the source for the db with command : DATABASE_SOURCE [path to sql]
  8. Finally Your tables are imported

Or, you can shorten above steps and use a single command to import the database . Run the following in the command line.                                                                                                                                                                                                             – MYSQL_BIN_FOLDER>mysql -u USERNAME -p DATABASE_NAME < DATABASE_SOURCE

After running the above command, it asks for a password. Enter the correct password and the all the tables of related db are imported.

Hits: 3365