Import database mysql command line

Import database mysql command line

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.

Import database mysql command line steps:

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;

Import database mysql command line syntax

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

import database mysql command line

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.

Other important links

Mysql dump database

Mysql create database

Select database in mysql

Delete database in mysql

Import database mysql command line searches:

Tags: #mysql