How to Dump and Restore a Database in MySQL or MariaDB with mysqldump

banner dedicated

In this document, we will show you how to dump a database with mysqldump and restore it.

How to dump the database

mysqldump -u [username] -p [database] > this_database.sql

Restore procedure

If the Database exist, drop the database first.

mysql -u root -p
MariaDB> DROP DATABSE this_database;

You need now to create the empty database.

mysql -u root -p
MariaDB> CREATE DATABASE this_database;

You can now import the dump in your database server

mysql -u [username] -p [database] < this_database.sql

banner dedicated

Colo-Serv Communications has written 32 articles

Premium Dedicated Hosting Services

Leave a Reply

Your email address will not be published. Required fields are marked *

one × two =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>