Nandan Joshi
Nandan Joshi
~1 min read



Here’s very simple way to import MySQL database from any MySQL dump file with few easy commands.

First start MySQL by connecting to the host with username

$mysql -u [YOUR_USERNAME] -p -h [YOUR_HOST]

Fill up square brackets with your credentials. If you are working on personal computer, your host will most probably be localhost. -p is needed if you had set a password to your Username (which you always should).

Now you will be in MySQL prompt. Create a new database with your preferred name and exit from the prompt

    mysql> create database [NEW_DATABASE];
    mysql> exit;

If you want to replace existing database with same name, you must remove it (drop it) before creating it. This line should prepend above lines in MySQL prompt.

    mysql> drop database [OLD_DATABASE];

You are back to shell command prompt. You can simply import the data from dump file into newly created database.


That’s all. You’ve got your precious data in new database.