How to create database from a dump

I gonna use localhost for demonstration purpose, but it’s the same for any other host, except you need to supply login and password to access the db.

Let’s login to mysql console. We login as root, which is common for local database:

mysql -uroot

In mysql console we need to delete old database if it exists:

DROP DATABASE database_name;

Next, we need to recreate the database to be able to put dump data in it:

CREATE DATABASE database_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Now, exit from the console with ‘exit’ command.

Last step is to load data:

mysql -uroot database_name < ~/path/to/dump.sql

That’s it!

Wanna hire me for your next big project? Drop me a letter at ykas.gg@gmail.com

Show your support

Clapping shows how much you appreciated Yuri Kasperovich’s story.