Ability to sustain, import and export database is a necessity for database administrator to preserve smooth operations of a system. You may prefer to store database files locally and export it to production database in case you need it for quicker disaster restoration. Widely used database such as MySQL and MariaDB have similar approach in term of backup and recovery. Database dump is uncomplicated approach to deal with import and export of MySQL and MariaDB. In this section, We will begin learning the process on the most effective way to do import and export of database in this tutorial.
Exporting database from server require database and login privilege. With my case I login using Putty with root access to my laptop running Ubuntu linux with MariaDB installed. after login I execute mysqldump command to export slave01 database to file slave01.sql
- Database name need to be export : slave01
destination filename : slave01.sq
// slave01.sql is the name of mysqldump file. From terminal run following
$mysqldump -u root -p slave01 > slave01.sql
// Wait for while until export process complete
After completion you will have file slave01.sql on current directory. Run ls -al slave01.sql to list the file. You can transfer the file out from your database machine for backup or import to another database.
// login to MariaDB as root mysql -u root -p
// we create database called slave03 database CREATE DATABASE slave03;
// slave01.sql is the name of mysqldump file from import step. From terminal run following mysql -u root -p slave03 < slave01.sql
As we reach the conclusion, we went to to process to import and export MariaDB database run on Ubuntu Linux. You may find it the method was straightforward. Similar method may apply to MySQL. If you want to learn more, please visit official mysqldump website.