Linux

Exporting and Importing MariaDB/MySQL Databases

November 12, 2022 jhudgins 1 min read

To export a database use the following command:

mysqldump --add-drop-table -u username -p dbname > dbname.sql

NOTE:
Omit the –add-drop-table argument if you plan to merge this backup with an existing database when you import it. This option means the backup will totally replace the old database when it is imported.

Import the database by executing the following command:

mysql -u username -p dbname < dbname.sql

Leave a comment