We use mysqldump command to get database backups or move data between servers. mysqldump command generates backups in SQL format.
On contrary of backup process, you don’t need to use a special command to import backups files back into mysql.
If you didn’t create database before and your backup file doesn’t contain CREATE DATABASE
command, you have to create database first,
$ mysqladmin -u username -p create database_name
Then you can use one of the following commands to import your SQL-formatted backups.
Option 1
$ mysql -u username -p database_name < backup_file.sql
Option 2
$ cat backup_file.sql | mysql -u username -p database_name
Option 3
$ mysql -u username -p database_name source backup_file.sql
If you use gzip to compress backup files, you have to use zcat command instead of cat command:
$ zcat backup_file.sql.gz | mysql -u username -p database_name