How to Backup MySQL Databases

This can be used to back up a database.

1. Export A MySQL Database

This example shows you how to export a database. It is a good idea to export your data often as a backup.

# mysqldump -u [username] -p [password] [database_name] > FILE.sql

Replace [username], [password] and [database_name] with your MySQL username, password and database name.

File FILE.sql now holds a backup of your database, download it to your computer.

2. Import A MySQL Database

Here, we import a database. Use this to restore data from a backup or to import from another MySQL server.

# mysql -u [username] -p [password] [database_name] < FILE.sql

Replace [username], [password] and [database_name] with your MySQL username, password and database name.

This command will backup your database. Simply export your data to a safe place for safe keeping.

Was this answer helpful?

 Print this Article

Also Read

How to Create a Subdomain in cPanel

A subdomain is a subsection of your website that exists as a subdirectory in your public_html...

Removing cPanel Accounts with /scripts/removeacct Script

The /usr/local/cpanel/scripts/removeacct script terminates cPanel accounts from the command line....

Using .htaccess File to Block IPs

You may block access to your website from specific IP addresses using .htaccess file. You need to...

Disabling mod_security in cPanel

Mod_security is an apache module that helps to protect your website from various attacks. It is...

Creating a Spam Email Filter

To create a spam filter, perform the following steps: Navigate to cPanel's  Apache...