请前往 模块插件 激活 UI Manage 然后刷新
Global Clouddy

Account Center

Support

  1. Portal Home
  2. Knowledgebase
  3. Backup
  4. How To Backup, Restore or Transfer MySQL/MariaDB Databases on Ubuntu
Login
Knowledgebase

How To Backup, Restore or Transfer MySQL/MariaDB Databases on Ubuntu

Today, Backup is a significant procedure and a very important part of working with databases. Regardless of whether you use a corporate website or just host WordPress, it is important to back up your databases. The backup storage is necessary in order to be able to restore information in a very quick and convenient way, in the event that a working copy of the information may be lost for any reason: restoration of documents, settings, certain programs and other things.

 

Backup process

We recommend a way to back up a MySQL or MariaDB database using the mysqldump dump command.

 

echo "SHOW DATABASES;" | sudo mysql

This command displays a list of your databases. Make sure you know which .sql file you need, and then simply run the following command to backup to the file.

 

sudo mysqldump example_database > $(date +"%F").sql

The command described above will back up the example_database to a file with a date ending in .sql. It is also possible to change the name of this file to any other, although saving the file name as a date will be useful if you accidentally delete an important row or column. Use date –help to learn about other ways to style your date.

 

Recovery

Here you need to find the .sql file that you created and run the following:

 

sudo mysql example_database < filename.sql

Migrating to MariaDB from MySQL

The first thing to do is back up each of your databases:

 

sudo mysqldump example_database > example_database.sql

After that, you will need to install MariaDB, which will replace MySQL, and restore your databases by following these steps for each database.

 

sudo mysql example_database < example_database.sql

  • 781 Users Found This Useful
Was this answer helpful?

Related Articles

How To Make Backup And Restore PostgreSQL Databases on Ubuntu 18.04

PostgreSQL is a open source database management system that can be used to store information...

How To Drop a Database on MySQL

MySQL is a Relational Database Management System that is known for being very easy to use, nice...

How to back up MySQL databases

MySQL is the most popular database software in the world. It's important to make sure you have a...