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

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

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;
exit


You need now to create the empty database.

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


You can now import the dump in your database server

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


Colo-Serv Communications has written 20 articles

Premium Dedicated Server in Canada

Leave a Reply

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

17 − 11 =

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>