1. Import

I assume you have SQL file(database) which you want to import using cmd. For example, we have stud.sql database file

First, let’s just create a database from http://localhost/phpmyadmin/ And suppose we created a database named students

If you are using WampServer go to wamp64\bin\mysql\mysql5.7.11\bin(for me it is this directory) place your SQL file(stud.sql) here in this folder

If you are using XAMPP go to xampp\mysql\bin place your SQL(stud.sql) file here in this folder

Open cmd and go to above path where we put our SQL file. Like for me, it is

And Run below command. Here username will be your username(It is root for me)

1. Run command

hit Enter and it will ask for the password. If you have one enter it and if you don’t just hit Enter again.

2. Then Run command to select database

hit Enter

3. After that Run this command to specify file we want to import

hit Enter

And your import process it started.

Well, there is also a short way of doing this. Just go to the  C:\xampp\mysql\bin>  and run below command

and read this here that says It is better to use the full path of the SQL file.

so I tried it and it works if your SQL file is at desktop no problem. Run command like below

 

2. Export

To export database,  I just have this. You can run below command in cmd from the same directory C:\xampp\mysql\bin>

And your exported SQL file will be at C:\xampp\mysql\bin\studentsbkp.sql

Be kind to one another. Take care!

No Comments

Post A Comment