For this we must have a DOT SQL file which holds the data to be imported to the database/ table.
Lets call the
DOT SQL file as importdata.sqlOpen the command line interface or terminal first.
DB Username as dbuser
Database Name as testDB
Move to the folder where the file importdata.sql is present.
Assuming that it is present at this location
/home/developer/Downloads/importdata.sqlMove to file folder
cd /home/developer/Downloads/Now we will have to check if the database is existing or not.
If its existing then run command
mysql -u dbuser -p testDB < importdata.sqlIt will ask you for the password for database user.
If we need to make a new database then first create the database as
CREATE DATABASE testDB;Now above command can be run to import the data as
mysql -u dbuser -p testDB < importdata.sqlIt will ask you for the password for database user.
Now the data from the sql file is imported to Mysql.
Happy Coding :)