narbulut

How to Back Up a MySQL Database?

14 May, 2026

A database is one of the most valuable digital assets a business owns. A hardware failure, a mistaken DROP TABLE command, a ransomware attack, or a simple human error — any of them can wipe out years of data in seconds. That is exactly why a regular, properly configured backup strategy is not a preference but a necessity.

In this guide we will cover all the common methods of backing up your MySQL database, step by step, using both command-line and graphical user interface (GUI) tools. By the end, you will have the knowledge to choose the method that best fits your needs and to automate your backup process.

Why Is Backup Critical?

Most data loss happens when you least expect it. Each of the scenarios below has actually happened to real businesses:

  • Physical data loss due to disk failure
  • Accidentally deleted tables or records
  • Data encrypted by ransomware
  • A failed application update corrupting the data
  • Inconsistencies that occur during a server migration

A backup strategy is not just about “taking backups”; it covers the right method, the right frequency, and a tested restore plan. Because a backup that has never been tested is a backup that does not exist.

Before You Start: 3 Key Concepts You Should Know

Before moving on to the methods, let’s briefly get to know the three key concepts that shape a sound backup strategy.

RPO and RTO

RPO (Recovery Point Objective) describes your maximum acceptable data loss: “At most, how many hours of data can I afford to lose?” RTO (Recovery Time Objective), on the other hand, answers the question “In the event of a disaster, how quickly do I need to bring the system back up?” These two targets determine your backup frequency and method.

The 3-2-1 Rule

The golden rule of a solid backup strategy is this: keep 3 copies of your data, store them on 2 different media, and keep at least 1 copy off-site (for example, in the cloud). A single backup does not count as a backup.

A backup isn’t a backup until it’s tested

A backup that has never been restored is nothing more than a hope you can’t be sure works. That is why this guide also covers the restore steps.

The Difference Between Logical and Physical Backup

In MySQL, backup methods fall into two main categories. To choose the right tool, it is important to understand the difference between them.

Logical Backup

The structure and data in the database are exported to a text file in the form of SQL commands such as CREATE TABLE and INSERT. It is hardware-independent, portable between different MySQL versions, and human-readable. mysqldump, MySQL Workbench, and phpMyAdmin fall into this category. Its drawback is being slow on large databases.

Physical Backup

The raw files of the database on disk (.ibd, redo log, etc.) are copied directly. It is much faster and ideal for databases hundreds of GB in size. Percona XtraBackup falls into this category.

FeatureLogicalPhysical
OutputSQL text fileRaw data files
SpeedSlowFast
PortabilityHighLow (version-dependent)
Suitable data sizeSmall–mediumLarge (100 GB+)
Version migrationEasyLimited

Method 1: Backup from the Command Line with mysqldump

mysqldump is the most widely used logical backup tool that ships with MySQL. It requires no extra installation. On Windows, if MySQL is installed, mysqldump.exe is located in MySQL’s bin folder (for example C:\Program Files\MySQL\MySQL Server 8.4\bin).

Basic usage

Open Command Prompt (CMD) or PowerShell and run the following command to back up a single database:

mysqldump -u root -p --single-transaction narbulut_test > C:\Backups\backup.sql
mysqldump command in CMD
Running the mysqldump command in CMD

When you run the command you will be prompted for a password; after entering it, the backup.sql file is created in the folder you specified. The --single-transaction parameter here lets you take a consistent backup of InnoDB tables without making the database read-only, which is critical on live systems.

When you open the resulting file in a text editor, you will clearly see that a logical backup is in fact just a series of SQL commands:

backup.sql file content
The resulting backup.sql file is just a series of SQL commands

Commonly used parameters

To back up all databases at once:

mysqldump -u root -p --all-databases > C:\Backups\all_databases.sql

To back up only the structure (without data):

mysqldump -u root -p --no-data narbulut_test > schema.sql
TIP: Compressing the backup file saves significant disk space on large databases. On Windows, after taking the backup you can archive it with a tool like 7-Zip.

Restoring a mysqldump backup

Restoring from the command line is quite simple:

mysql -u root -p narbulut_test < C:\Backups\backup.sql
mysql restore command in CMD
The mysql restore command in CMD

Before restoring, make sure the target database exists. If necessary, create it first with CREATE DATABASE narbulut_test;.

IMPORTANT: Regularly test restoring your backup in a test environment. Trying a restore for the first time during a real disaster is the worst-case scenario. An untested backup is an unreliable backup.

Method 2: Backup with MySQL Workbench

For those who would rather not work on the command line, MySQL Workbench is the official, free graphical interface. It lets you back up with just a few clicks.

MySQL Workbench main screen
MySQL Workbench main screen

Step-by-step backup

Open Workbench and log in by clicking your database connection. Switch to the Administration tab on the left menu and click Data Export. On the screen that opens, check the databases and tables you want to back up.

Workbench Data Export selection
Selecting databases and tables on the Data Export screen

Then, in the Export Options section, choose how the backup will be saved. The Export to Self-Contained File option collects the entire database into a single .sql file and is the most practical method for migration. For a consistent backup, it is also recommended to check Include Create Schema.

Workbench export options
Export Options: Self-Contained File and dump options

Click the Start Export button and wait for the process to complete. When it finishes, you will see a completion message in the bottom panel.

Workbench export completed
Workbench export completed

Restoring with Workbench

For restoring, you use the Data Import/Restore screen. With the Import from Self-Contained File option you point to the .sql file you took earlier, select the target schema (Default Target Schema), and click Start Import.

Workbench Data Import Restore
Data Import/Restore screen

When the process completes, your backup will have been restored.

Workbench import completed
Workbench import completed

Method 3: Backup with phpMyAdmin

For those who use shared hosting or prefer a web-based interface, phpMyAdmin is the most practical solution. It comes ready in most hosting packages.

Export

Log in to phpMyAdmin and select the database you want to back up from the left menu. Click the Export tab in the top menu. The Quick method is sufficient for most cases; the format should be set to SQL. If you want more control, you can use the Custom option.

phpMyAdmin Export
phpMyAdmin Export tab

When you click the Go button, the .sql file downloads to your computer.

Import

Select the database you want to restore (or create an empty database), switch to the Import tab, choose your .sql file with Choose File, and click Go.

phpMyAdmin Import
phpMyAdmin Import tab
WARNING: phpMyAdmin has a default file upload size limit (usually a few hundred MB). For large databases, mysqldump or Workbench is more reliable.

Method 4: Hot Backup with Percona XtraBackup

For live production databases that are hundreds of GB or TB in size, logical methods are too slow. This is where Percona XtraBackup comes in.

XtraBackup is an open-source hot backup tool; that is, it takes a physical copy of the InnoDB data files without stopping or locking the database. While the database keeps responding to queries, it copies pages from disk in the background and produces a consistent backup using InnoDB’s crash recovery mechanism.

Its main advantages:

  • Backup with zero downtime
  • Much faster restore than mysqldump on large databases
  • Point-in-Time Recovery support through incremental backups
  • Compression and encryption features
NOTE: Percona XtraBackup runs only on Linux. It cannot be used directly on Windows servers; in that scenario you take the backup from a Linux replica. The MariaDB equivalent is Mariabackup.

Binary Log and Point-in-Time Recovery (PITR)

Taking only a daily full backup is not always enough. Say you took your backup at 02:00 at night and the data loss occurred at 15:00 in the afternoon. What happens to the 13 hours of data in between?

This is where the Binary Log (binlog) comes in. The binary log records all changes made to the database (every INSERT, UPDATE, DELETE) in order. By combining your full backup with the binlog, you can roll back to a specific point in time. For this reason, a serious backup strategy keeps full backups together with copies of the binary log. One of the greatest strengths of tools like XtraBackup is this PITR capability.

Automating Backups: Windows Task Scheduler

Manual backup is doomed to be forgotten. A reliable strategy must be automatic. On Windows, we do this with Task Scheduler.

1. Creating a backup batch file

First, prepare a .bat file that takes the backup. For example C:\Backups\backup.bat:

@echo off
set DATE=%date:~-4%-%date:~3,2%-%date:~0,2%
"C:\Program Files\MySQL\MySQL Server 8.4\bin\mysqldump.exe" -u root -pPASSWORD --single-transaction narbulut_test > C:\Backups\backup_%DATE%.sql

When this script runs, it produces a backup by appending the date to the file name (backup_2026-06-04.sql).

2. Creating a task in Task Scheduler

Type Task Scheduler in the Start menu and open it. From the panel on the right, choose Create Basic Task and give the task a name.

Task Scheduler create basic task
Task Scheduler — Create Basic Task (task name)

In the Trigger step, choose how often the backup will run (for example, every day at 02:00).

Task Scheduler trigger
Task Scheduler — Trigger / scheduling step

In the Action step, choose Start a program and point to the .bat file you created.

Task Scheduler action bat
Task Scheduler — Action / selecting the .bat file

Complete the wizard. From now on, your backup will be taken automatically every day. After a few days, you will see dated files accumulating in your backup folder:

Dated backup files
Dated backup files accumulating in the C:\Backups folder
TIP: Keeping backups only on the same server is risky. If the server fails completely, the backups are gone too. Always copy your backups to a different location or to the cloud.

Best Practices

Follow these principles for a solid MySQL backup strategy: apply the 3-2-1 rule so that you keep at least 3 copies, on 2 different media, with 1 copy in a different location. Set a regular schedule based on how often your data changes, and take large backups during low-traffic hours such as at night. Use --single-transaction for consistency on InnoDB tables, keep the binary log enabled for point-in-time recovery, and most importantly, test the restore process regularly. Local backups alone are not enough; always keep an off-site or cloud copy.

Keep Your Data Safe in the Cloud

The most critical link in your backup strategy is storing backups in a secure location that is independent of the physical server. A backup taken to a local disk can be lost together with the primary data in the event of fire, theft, hardware failure, or ransomware.

Narbulut Cloud Backup solutions provide an automated, encrypted, and KVKK-compliant off-site backup layer for your MySQL databases and all your critical data. Your data is stored in data centers in Türkiye, in full compliance with legal regulations; this completely eliminates the question “I have a backup, but where is it and is it safe?”

Take Your MySQL Backup Processes to a Professional Level

If you need a professional cloud backup solution for your database backup processes, you can explore Narbulut solutions.

Explore the MySQL Backup Solution

Leave a Comment

Your email address will not be published. Required fields are marked *

Narbulut Product Analysis

Step 1/12
What area of technological improvement are you planning for your company?
Data Security & BackupRansomware, deleted files and disaster recovery.
Cloud Server (IaaS)Website, ERP, CRM or application hosting.
Team CollaborationSecure file sharing and remote work.
Object Storage (S3)Object Storage for developers.
What industry does your company operate in?
Healthcare / MedicalPatient data (GDPR critical).
Finance / AccountingSensitive financial data.
Manufacturing / EngineeringCAD drawings and production plans.
Other / General ServicesOffice documents and general data.
What type of devices need to be protected?
Employee ComputersLaptop and desktop end-user devices.
Physical / Virtual ServersDatabase, Active Directory or File Server.
What should your backup strategy be?
File & Folder BasedOnly important business files (XLS, PDF, SQL) should be backed up.
Full Disk ImageBack up "Everything" including the operating system.
What is your upload speed for cloud backup?
Fiber / High SpeedI can send large data quickly.
Standard / ADSLMy speed is limited, compression is important.
Is ransomware a threat?
Yes, Very CriticalWe have experienced it before or are at risk.
Standard Protection is SufficientBasic backup measures are enough.
How long would you like to keep versions?
90
30 - 90 DaysTo fix recent errors.
365+
1 Year and AboveLegal requirements or archiving.
What will be the primary purpose of the server?
E-Commerce / WebsiteHigh uptime and speed required.
ERP / Accounting SoftwareDatabase performance is important.
Software DevelopmentFlexible resource management.
What infrastructure do you need?
Windows ServerASP.NET, MSSQL, RDP.
Linux (Ubuntu/CentOS)PHP, Python, MySQL, Docker.
What is the estimated user traffic?
Low / MediumEntry level or new project.
High TrafficHeavy campaigns or many users.
Who will manage the server?
I Will Manage ItI have a technical team, root access is enough.
I Need SupportManaged Services required.
How many people will work in the shared workspace?
1 - 10 UsersSmall teams.
10 - 50+ UsersDepartment-based permissions required.
Is remote access required?
Yes, DefinitelyField team needs to upload files from mobile.
No, Office OnlyAccess only from company computers.
Analyzing Your Responses...
BEST SOLUTION FOR YOU

Product Title

Description

Explore Product Now

Product Information Request

Fill out the form so our solution experts can contact you.

Size uygun Narbulut Cloud Server planlarına göz atın

Narbulut Cloud Server ile ihtiyaçlarınıza en uygun sunucuları yapılandırın.

    SUNUCU TEKLİF & YAPILANDIRMA FORMU

    1. KURUMSAL KİMLİK & İLETİŞİM
    2. TEKNİK GEREKSİNİMLER
    3. LİSANS YÖNETİMİ

    Check out Narbulut Cloud Server plans that suit you

    Configure the servers that best fit your needs with Narbulut Cloud Server.

      SERVER QUOTE & CONFIGURATION FORM

      1. CORPORATE IDENTITY & CONTACT
      2. TECHNICAL REQUIREMENTS
      3. LICENSE MANAGEMENT

      Narbulut Mobile’ı İndirin

      Uygulamayı indirmek istediğiniz platformu seçin

      Download Narbulut Mobile

      Select the platform you want to download the app

      ×