Blog Bustle 19/02/2020
We can import database in mysql server from command line. It is very fast process to upload data in less time.
Let's know how can we import sql file in mysql database.
First create database in mysql server before running import database mysql command line if you want to import sql file into new database
Mysql create database syntax
create database database_name;
mysql -u [username] -p[password] [database_name] < [dump_file_name.sql];
For example, we are going to import db1.sql file into mysql student database
Step 1: go to mysql folder directory.
Step 2: then go to bin directory inside mysql.
Step 3: write command "mysql -u root -p student < d:\db1.sql"
Step 4: Enter password
here username is root, password is empty, student is database and we uploaded db1.sql from d drive of computer
So these were the steps of import database mysql command line.
We have successfully uploaded all data in student database.
So we saw it is simple and easy process.
We can import sql file on any server.
We select database before running import database mysql command line. If we do not select database and import sql file directly we will get 'no database selected' error.