How to Import a MySQL Database Dump or Backup


2013-06-18

Now that we have covered how to make a backup of your MySQL database, we can go over how to import the backup. To do this, you can use the cat command:

cat thebackupfile.sql | mysql -D mydatabase -u myusername -p

This command uses cat to write your database to stdout and then pipes it into mysql. You'll need to have your database created first, but you can do that with:

mysql -u myusername -p -e "create database mydatabase"

Tags: MySQL