How to import data into mysql db from sql file

Open your shell prompt

navigate to the mysql directory (default is /var/lib/mysql)
cd /pathToYourMysqlDirectory/

then type the below command

$ mysql -u mysqlUserName -p Password -h HostName DatabaseName < /loactionOfYourSqlFile/yourSqlFileName.sql

Where
mysqlUserName = Mysql User Name
Password = Mysql User Password
HostName = Mysql Host Name (This could be local host or some remote IP where you want to import the database)
DatabaseName = Mysql Database Name
/loactionOfYourSqlFile/yourSqlFileName.sql = This is the location of your sql file

Note : This is work only in Linux system

Thanks

Leave your comment