How to import SQL file to MySQL using Command Line ?

13-Jun-2020

.

Admin

Hi Guys,

In this tutorial,I will learn you how to import sql file to mysql using command line. you can easy and simply import database.

you can import sql file to mysql using command line and without command.

Step 1 : Create Database


First step, Open XAMPP and start Apache Server and MySQL Database.you can need to Mysql database. then open phpmyadmin and create a new database.

I have create a demo database.

Step 2 : Using Command + Without Command

Solution 1 : Using Command

you can open command prompt then open directory xampp/mysql/bin/

then follow this command

Syntax :

mysql -u username -p database_name < file.SQL

username = Your MySQL username.

database_name = Database name in which you want to import.

file.sql = SQL file name.

Example :

 

mysql -u root -p demo < demo.sql

I am importing demo.sql file in demo Database.

Solution 2 : Without Command

In this step without command import to database in phpmyadmin.

1. first click to import

2. Then choose file Click

3. choose the Sql file

4. Last go button click

5. create to database

It will help you...

#Windows