►Quick Search:
Preface
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.
[5 Easy Ways] How to Backup MySQL Database
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.
Method 1: Using Command Line (mysqldump)
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:
- A Linux operating system
- MySQL installed
- Existing database
- Mysqldump utility (should be included with your MySQL software)
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
- Replace [user] with your username and password (if required).
- The [database_name] is the path and filename of the database.
- The > command specifies the output.
- The [filename] is the path and filename you want to save the dump file as.
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.
Method 2: Using MySQL Workbench
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
- Press win+R;
- Enter services.msc;
- Find the MySQL Server service in the service list;
- Right-click on it and select Stop;
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:
- Backups can only be ported to other machines with the same or similar hardware characteristics.
- The solution for creating a hot backup can be too expensive for small businesses, as the only Windows tool that allows you to create a physical backup without stopping the server is MySQL Enterprise Backup.
Method 3: Using phpMyAdmin
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.
Method 4: Backup Website (Files + Database) to Cloud via "Website Backup"
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:
- Scheduled backup: You can back up data to other cloud accounts daily, weekly or monthly.
- Fast backup: When the advanced version is enabled, MultCloud can provide you with a high-speed backup mode, which can save a lot of time.
- Restore at any time: After the task is enabled, you can find the backup data to restore.
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.
- Select your website files and MySQL database as the Source.
- Select a cloud drive (e.g., Google Drive, OneDrive, or S3) as the Destination.
4. Execute: Click "Backup Now." You can also use the Schedule option to run this daily or weekly.
Method 5: Backup MySQL to Another Host via "Website Clone"
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.
- One-Stop Copy: Copy both your MySQL database and your website files (via FTP/SFTP) in a single task.
- Easy Migration: Perfect for migrating your website to a new host or domain.
- Offline Execution: Once the task starts, MultCloud processes the backup on its servers, so you can turn off your computer.
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.
Summary
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.
FAQs
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.
MultCloud Supports Clouds
-
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