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


banner dedicated


Colo-Serv Communications has written 32 articles

Premium Dedicated Hosting Services