Monday, August 12, 2013

Back up and restore a MariaDB database on Debian Linux

The following commands work for me in MariaDB.

This one backs up the database called databaseName:

$ mysqldump -u root -p \
--set-charset \
--default-character-set=utf8 \
--databases databaseName \

These ones restore the database for me by using the SQL file:

$ mysql -u root -p

$ create database databaseName default character set utf8;

$ use databaseName;

$ source /path/to/sql/file/databaseName.sql;

The SQL file can be very big.
To reduce its size, do:

$ gzip -c databaseName.sql > databaseName_2013_08_12_09_30.sql.gz

Add the date and time for future reference.

To get back the SQL file, do:

$ zcat databaseName_2013_08_12_09_30.sql.gz > whateverName.sql


No comments: