MySQL : Importing Database Dump / Backup to MySQL Server

We can able to make dump of MySQL database as .sql file[Refer: MySQL : Backup / Dump MySQL Database in Windows and Ubuntu]. By using the dump of sql file we can import them to MySQL database using the mysql command "use FILE_NAME.sql". This will import entire database source file into database schemas and dataset to schemas. Import time is based on Dump size.

Login in to MySQL server then Type below command, Make sure Source file shoud be place on the Directory or Folder you have try to login.

Syntax:

1. Login in to MySQL server using username and password

> mysql -u USER_NAME -p

Note: Make sure Source file shoud be place on the Directory or Folder you have try to login.

2.  Create Database is not Exist.

> create database DATABASE_NAME;

Please skip if Database already exist.

3. Switch to the database.

> use DATABASE_NAME;

4. Import Database using "source" command

> source DATABASE_SOURCE_FILE.sql

Based on Dump size importing taken.

Example

1. Login in to MySQL server

> mysql -u codeexpertz -p

Sorce File:

   db_sample_backup_16112016.sql

2.  Create Database is not Exist.

> create database db_sample_new;

Please skip if Database already exist.

3. Switch to the database.

> use db_sample_new;

4. Import Database using "source" command

> source db_sample_backup_16112016.sql

Based on Dump size importing taken.

Category: