Are you afraid of losing your MySQL database? It is important to back up all data regularly to prevent loss. This article describes how to backup MySQL database to a local or another server. You can choose MySQL Workbench or phpMyAdmin to manually copy the backup or use Mysqldump to execute the command line. If the local storage space is not enough, you can also use MultCloud to back up the data to other servers.
►Quick Search:
Almost everyone these days knows that backups are important and that digital data stored on a computer can be lost or corrupted, not to mention databases stored on a server. If you are the administrator of the server, you should pay special attention to your data.
Many individuals and businesses choose to store their entire site's data in a MySQL database, which can be catastrophic if lost or corrupted. So, how to take a backup of a MySQL database? This article will provide the following 5 feasible ways.
When it comes to backing up MySQL, we have to mention "Mysqldump", which is a command-line tool provided by MySQL itself. If you have a shell or telnet access to the web server, you can use Mysqldump. The Mysqldump client utility can dump the database, including the SQL statements needed to rebuild the database.
Pre-requisites:
By default, the dump file contains SQL commands to restore tables and data. To back up a MySQL database, the general syntax is:
sudo mysqldump -u [user] -p [database_name] > [filename].sql
Other examples:
Back up the entire database management system: mysqldump --all-databases --single-transaction --quick --lock-tables=false > full-backup-$(date +%F).sql -u root -p
To restore data, use the following commands: mysql -u [user] -p [database_name] < [filename].sql
To include multiple databases in a backup dump file: sudo mysqldump -u [user] -p [database_1] [database_2] [database_etc] > [filename].sql
But the disadvantage of this method is obvious - the command line is very complicated, and the user has to remember a lot of commands. Well, there are other backup methods, such as copying compression, using third-party tools, etc.
The most straightforward way to create a MySQL backup is to simply copy the contents of the MySQL data directory. To manually create a file-based backup of MySQL server, follow these steps:
Step 1. Find the MySQL Server data directory, the easiest way is through MySQL Workbench. To do so, run this command:
select @@datadir;
Step 2. Find and stop the MySQL server service
Step 3. Copy or package the contents of the MySQL server data directory to another location.
Step 4. Start the MySQL server by clicking "Start" in the context menu of the service.
However, physical backups have two important disadvantages:
You can easily create a dump file (export/backup) of the databases used by your account. At this point, you can do it by visiting the phpMyAdmin tool available in cPanel.
Step 1. Open phpMyAdmin from your web hosting control panel such as cPanel.
Step 2. Select databases from phpMyAdmin's sidebar navigation panel.
Step 3. Click the "Export" option in the top navigation bar.
Step 4. On the export page, select the export options: Quick and Custom. For your convenience, you can choose the "Custom" option.
Step 5. Select the table to be backed up. When you select the "Custom" option, the page will allow us to choose which tables to back up. If you're not sure what to choose, leave it as is (all tables are selected by default).
Step 6. Select the "Compression" option as gzipped and leave the rest unchanged.
Step 7. Click the "Go" button, then your backup file will be downloaded automatically. The file name will be NameOfYourDB.sql.gz file. Depending on the size of your database, this process may take some time.
If you are managing a website (like WordPress), backing up just the database isn't enough; you also need your website files. MultCloud has launched a new "Website Backup" feature specifically designed to back up your site files and database simultaneously to the cloud.
Compared to other tools, MultCloud can give you more benefits:
How to use Website Backup:
1. Sign Up: Create a free account at MultCloud. Enter your email address and password to register. Alternatively, you can authorize login directly using your Google and Facebook accounts.
2. Add Services: Click "Add Cloud", then choose "Website" to add your website's FTP/SFTP account. Then, add your MySQL database.
3. Configure Website Backup: Go to the "Website Backup" tab.
4. Execute: Click "Backup Now." You can also use the Schedule option to run this daily or weekly.
When you need to migrate your website or create a redundant "mirror" site on another server, MultCloud's "Website Clone" (powered by its advanced transfer engine) is the most efficient method.
How to use it:
1. Add Both Hosts: Add the MySQL and FTP details for both your Source Host and your Target Host into MultCloud.
2. Select Website Clone: This tool is designed to migrate the entire environment.
3. Map the Migration: Select the original database and files from the source host and set the destination as the new host's directory.
4. Clone: Click "Clone Now." MultCloud will move the data directly from server to server without requiring you to download files to your local computer.
Whether you prefer the control of the Command Line or the simplicity of phpMyAdmin, backups are non-negotiable. For modern webmasters, MultCloud offers the most comprehensive solution: use Website Backup for daily cloud protection and Website Clone for seamless server-to-server migration.
In addition, it is worth mentioning that MultCloud, as a multiple cloud storage manager, supports 40+ cloud storage services, which can help you better manage multiple cloud storage accounts.
Dropbox, Dropbox Business, Google Drive, Google Workspace, Google Photos, iCloud Photos, iCloud Drive, OneDrive, SharePoint Online, OneDrive for Business, MEGA, Flickr, Box, Box for Business, pCloud, Amazon S3, Wasabi, SugarSync, Evernote, CloudMe, Cubby, MyDrive, WEB.DE, Yandex, HiDrive, MySQL, Egnyte, Putio, Backblaze, MediaFire, ownCloud, ADrive, Baidu, even NAS, WebDAV, FTP/SFTP, Shared with me and Shared Drive.
If you want to sync files, "Cloud Sync" can help sync files between multiple cloud storage services in real time. By the way, by sharing MultCloud to your social accounts and submitting the sharing link, you will have a chance to get LIFETIME UNLIMITED data traffic in MultCloud.
1. What are the different backup formats available for MySQL databases?
MySQL databases can be backed up in various formats, such as SQL, CSV, XML, or compressed formats like Gzip or Zip. The SQL format is the most common as it allows for easy restoration and is supported by most MySQL tools.
2. Should I lock tables while performing backups?
InnoDB tables support online backups, which means you can perform backups without locking the tables. However, for MyISAM tables, it is recommended to lock the tables during the backup process to ensure data consistency.
3. Where should I store my MySQL backups?
Store your MySQL backups in secure, off-site locations, such as external hard drives, network-attached storage (NAS) devices, or cloud storage platforms. This helps protect your data from physical damage or local disasters.
4. How often should I back up my MySQL database?
The backup frequency depends on your data's criticality and how frequently it changes. For critical data, it's best to perform daily or incremental backups, while less critical data may require weekly or monthly backups.
5. Can I use MultCloud to migrate a database to a different server?
Yes. By using the Website Clone or Cloud Transfer feature, you can move your MySQL database directly from one host to another without the manual export/import hassle.
6. How does MultCloud "Website Backup" differ from regular "Cloud Transfer"?
Cloud Transfer is designed to move individual files or the database itself. The Website Backup feature is a specialized tool that bundles your website's file directory (via FTP) and your MySQL database into one single backup package, making website recovery or migration much easier.
Google Drive
Google Workspace
OneDrive
OneDrive for Business
SharePoint
Dropbox
Dropbox Business
MEGA
Google Photos
iCloud Photos
FTP
box
box for Business
pCloud
Baidu
Flickr
HiDrive
Yandex
NAS
WebDAV
MediaFire
iCloud Drive
WEB.DE
Evernote
Amazon S3
Wasabi
ownCloud
MySQL
Egnyte
Putio
ADrive
SugarSync
Backblaze
CloudMe
MyDrive
Cubby