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 :
- Open the command line : Click Windows + r, type cmd and enter
- 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
- Run MySQL in command line i.e MySQL -u root -p
- It will ask for MYSQL root password. Enter password ( if it is empty, simply press enter )
- 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
- To import the tables in the new or existing database, type the following in command : USE db_name;
- 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]
– source DATABASE_FOLDER_PATH\DATABASE_NAME - 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.
Views: 12471