Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
VGSources
Blog

How to Back Up a MySQL Database With mysqldump

Use mysqldump to create a logical SQL backup, choose --single-transaction --quick for mostly-InnoDB online snapshots, include routines and events deliberately, and verify recovery with a real restore.
Length10 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a straightforward logical backup, run mysqldump -u USER -p DATABASE > backup.sql. For an online backup of an InnoDB database, use mysqldump -u USER -p --single-transaction --quick DATABASE > backup.sql. The second form takes a consistent transactional snapshot without blocking normal application reads and writes, but it does not provide the same guarantee for MyISAM or MEMORY tables.

What mysqldump creates

mysqldump creates a logical SQL export. The output is a text file containing SQL statements that can recreate database objects and insert table rows. Restoring it means running those statements through the mysql client; it is not a byte-for-byte copy of the database files.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

That distinction determines when this method is appropriate. A logical dump is portable and easy to inspect, but a large file can take a long time to reload. If your recovery objective requires a restore measured in minutes while a logical reload would take hours, the MySQL manual points to a physical backup approach such as MySQL Enterprise Backup instead.

Choose the command that matches your database

Need Command What it does
One database, basic dump mysqldump -u USER -p DATABASE > backup.sql Writes the selected database’s SQL to backup.sql.
One mostly-InnoDB database while it remains online mysqldump -u USER -p --single-transaction --quick DATABASE > backup.sql Starts a consistent transaction for transactional tables and reads rows incrementally.
Several named databases mysqldump -u USER -p --databases db1 db2 > backup.sql Includes CREATE DATABASE and USE statements for each named database.
All databases on the server mysqldump -u USER -p --all-databases --routines --events > all.sql Dumps every database and explicitly includes stored programs and scheduled events. MySQL 8.4 requires the explicit routine and event options for this purpose.
Application database with non-table objects mysqldump -u USER -p --single-transaction --quick --routines --events --triggers DATABASE > backup.sql Captures the transactional snapshot plus routines, events and triggers.

Replace USER and DATABASE with the account and database names used by your deployment. The -p option prompts for the password rather than putting it in the command line.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Prepare before starting a dump

Confirm the database scope

Decide whether the recovery target is one game-service database, several related databases, or the entire server. The --databases form is useful when a single file must recreate more than one named database because it embeds database-creation and database-selection statements. A dump of one database does not automatically include other databases on the same server.

Check the table engines

--single-transaction is designed for transactional tables such as InnoDB. It establishes a transaction at the default REPEATABLE READ isolation level and reads a consistent state from the moment the transaction starts without blocking applications. MyISAM and MEMORY tables are not covered by the same consistency guarantee. If a schema mixes engines, treat the dump as potentially inconsistent across those nontransactional tables and plan a method appropriate for the data that must agree at one point in time.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Plan the account’s privileges

Do not wait for a scheduled job to discover that its account is missing a privilege. The account generally needs:

  • SELECT on the tables being dumped.
  • SHOW VIEW for views.
  • TRIGGER for triggers.
  • LOCK TABLES when you are not using --single-transaction.

Some tablespace and GTID-related settings can additionally require PROCESS, RELOAD or FLUSH_TABLES. Grant only what the backup account and its selected options require, then run a test dump with the same account and connection settings that production will use.

Make room for the output

Shell redirection writes the SQL file on the machine where you run mysqldump, not necessarily on the database server. Ensure that location has enough free space and that the account running the command can create and protect the file. A successful command only says that the client finished writing output; it does not establish that another machine has a copy or that the file can be restored.

Back up one database step by step

  1. Open a shell on a host that can connect to the MySQL server.
  2. Run the online InnoDB form when the workload must remain available:
    mysqldump -u USER -p --single-transaction --quick DATABASE > backup.sql
  3. Enter the password when prompted. Keep the password out of shell history and process listings; the prompt provided by -p is preferable to placing a password after the option.
  4. Wait for the command to return. A shell prompt normally returns only after the SQL stream has been written; capture the command’s exit status in the job that runs it so failures are distinguishable from successful dumps.
  5. Check that the expected file exists, has a plausible size, and can be read by the account that will move or archive it. These checks catch an invalid output path or a zero-length result, but they do not replace a restore test.

For a simple database in which transactional snapshot behavior is not required, the shorter command is:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysqldump -u USER -p DATABASE > backup.sql

When --single-transaction is used, pairing it with --quick is recommended for large tables. The quick mode retrieves rows a table at a time instead of attempting to hold the full result set in client memory.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Include every object required by the application

Tables are only part of a working schema. Decide explicitly which executable and scheduled objects the restored environment needs.

Triggers

Triggers are included by default. Use --skip-triggers only when you deliberately want an export without them, such as a controlled schema-only workflow in which triggers will be supplied separately. Omitting a trigger can change application behavior after restore.

Stored procedures and functions

Add --routines to include stored procedures and stored functions. Do not assume that a command written for one release and dump mode handles these definitions identically in every other release.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Event Scheduler events

Add --events for scheduled Event Scheduler events. If a game service relies on an event to expire sessions, aggregate statistics, or perform other maintenance, leaving this option out can produce a database that loads successfully but behaves differently.

MySQL 8.4 and all-database dumps

With MySQL 8.4 and --all-databases, explicitly specify --routines --events when those definitions belong in the backup:

mysqldump -u USER -p --all-databases --routines --events > all.sql

Older releases handled these system definitions differently. If a backup script spans server versions, document the version-specific options and verify the resulting file contains the objects you expect.

Back up several databases in one file

Use --databases, also available as -B, followed by each database name:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
mysqldump -u USER -p --databases db1 db2 > backup.sql

This form writes CREATE DATABASE and USE statements before each database. During a reload, those statements can create and select the targets, subject to the privileges of the account performing the restore. Without --databases, a dump command normally targets the database named at the end of the command and does not embed the same database-creation workflow.

For an online multi-database dump in an InnoDB-heavy deployment, add --single-transaction --quick. Remember that the consistency guarantee still applies to transactional tables, not automatically to MyISAM or MEMORY tables.

What happens while --single-transaction is running

The option starts a transaction at REPEATABLE READ and captures the consistent state visible when that transaction begins. For InnoDB, this lets normal application activity continue without the table locks associated with a locking dump. It is therefore a strong default for a mostly-InnoDB production database that needs an online logical snapshot.

It is not a universal “no-impact” switch. The server still reads every row, the client still writes the entire SQL stream, and the workload must continue to support the transaction for the duration of the export. More importantly, the MySQL manual warns against structural changes to dumped tables during the operation. Avoid these statements until the dump completes:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • ALTER TABLE
  • CREATE TABLE
  • DROP TABLE
  • RENAME TABLE
  • TRUNCATE TABLE

Such DDL can make the consistent read incorrect or cause it to fail. Schedule migrations and maintenance that affect the dumped tables outside the snapshot window, or use a backup method designed for that operational requirement.

Restore a mysqldump file

Restore into an existing database

Create or select the destination database as required by your deployment, then stream the file to the mysql client:

mysql -u USER -p db_name < backup.sql

The account must have privileges to execute the statements contained in the file. That can include permissions to create tables, views, triggers, routines, events, and to insert or replace data, depending on what was dumped.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Restore a file made with --databases

A file created with --databases contains its own CREATE DATABASE and USE statements. Reload it through the client while supplying an account authorized to execute those statements:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysql -u USER -p < backup.sql

If the destination names must differ, do not blindly edit a production backup. First determine how the embedded statements select the database, then use a controlled copy and validate the resulting object names and references.

Prove that the restore is usable

  1. Restore the file into an isolated test instance or a disposable database, never over the only live copy.
  2. Check that expected tables, views, triggers, routines and events exist.
  3. Run representative read and write checks for the application, including any scheduled behavior that depends on Event Scheduler events.
  4. Record whether the restore completed with errors and how long it took. The elapsed time is the evidence you need when setting recovery objectives.

A dump command that exits successfully is not proof of recoverability. Only a completed, usable reload demonstrates that the file, account privileges and destination configuration work together.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

The dump stops with an access-denied error

Check the account’s host-specific grants and confirm that it has SELECT on every selected table. Add SHOW VIEW for views and TRIGGER for triggers. If the command omits --single-transaction, verify that LOCK TABLES is available or choose the transactional form where its consistency model fits the schema. Tablespace or GTID-related options can introduce PROCESS, RELOAD or FLUSH_TABLES requirements.

Views or triggers are missing

Confirm that the account has SHOW VIEW and TRIGGER privileges and that the command did not include --skip-triggers. Inspect the SQL file in a nonproduction copy for the expected object definitions before scheduling the job.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Stored programs or events do not appear after reload

Rerun the dump with --routines --events. For MySQL 8.4 all-database exports, these options should be explicit. Also check that the restoring account is allowed to create the definitions and that the destination server supports the objects being loaded.

The online dump fails during a schema change

Look for an ALTER TABLE, CREATE TABLE, DROP TABLE, RENAME TABLE or TRUNCATE TABLE affecting a dumped table. Reschedule the DDL outside the dump window and run the export again. Those statements can invalidate or interrupt the consistent read.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

The file restores but the application is inconsistent

Check whether the database uses MyISAM or MEMORY tables. The consistent snapshot guarantee of --single-transaction is for transactional tables such as InnoDB; nontransactional tables may not represent one common point in time. Review the restore test for missing routines, events or triggers as well.

The restore takes too long

Measure the actual reload duration rather than judging only by dump-file size. A logical export must execute SQL to rebuild objects and insert rows. If that duration exceeds the recovery time your service can tolerate, evaluate a physical backup strategy instead of adding more flags to the same logical dump command.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

mysqldump versus a physical backup strategy

Decision factor Logical mysqldump Physical backup approach
Representation SQL statements and row data that are re-executed during restore. Copies database storage structures or files for a physical recovery workflow.
Portability Generally convenient for moving logical schemas and data between compatible environments. Usually tied more closely to the server, storage layout and supported recovery tooling.
Transactional consistency --single-transaction provides the documented online snapshot behavior for transactional tables such as InnoDB; MyISAM and MEMORY need separate consideration. Depends on the physical product and its consistency mechanisms across the storage set.
Production impact Reads all selected data and writes a logical stream; DDL during the snapshot can invalidate it. Depends on the implementation and configuration.
Restore-time target Can become slow as the SQL file and object count grow. Worth evaluating when a logical reload would take hours or miss the recovery objective.
Point-in-time recovery Not supplied by a single mysqldump file. Assess the product’s documented support for point-in-time recovery and the operational cost of maintaining it.

The right choice is driven by restore-time targets, storage-engine consistency, workload impact, portability, point-in-time requirements and operating cost—not by the convenience of producing a file alone.

Turn the command into a dependable backup process

A practical runbook separates the dump itself from the controls around it:

  1. Define the recovery target. State which databases and objects must be recoverable and how quickly the service must return.
  2. Select the snapshot method. Use --single-transaction --quick for a predominantly InnoDB workload that needs an online logical snapshot. Reconsider the method if nontransactional tables must be mutually consistent.
  3. Include required objects. Add --routines and --events deliberately; leave triggers enabled unless there is a documented reason to skip them.
  4. Prepare privileges. Test the dump and restore accounts against the exact objects and options used in production.
  5. Control conflicting changes. Keep the listed DDL statements away from the affected tables while the snapshot runs.
  6. Validate every output. Check command status and file readability, then periodically reload a copy and exercise the application paths that matter.
  7. Measure recovery. Record restore duration and failures. Move to a physical strategy when the measured logical restore no longer meets the service’s target.

Policies mysqldump does not decide for you

The mysqldump documentation does not establish a universal retention period, encryption scheme, off-site-storage rule or restore-test schedule. Those are deployment policies. Set them according to the value of the data, regulatory obligations, acceptable loss and recovery-time targets, then verify them operationally. A SQL file left on the same host as the live database is not a complete disaster-recovery plan, and an encrypted archive that has never been decrypted and restored is not a tested backup.

Recommended command for a game-service database

For a database that is primarily InnoDB and must stay online while its player, inventory or session data is exported, start with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysqldump -u USER -p --single-transaction --quick --routines --events --triggers DATABASE > backup.sql

Use the shorter form when those additional object types are not part of the application, use --databases when the file must recreate several named databases, and use --all-databases --routines --events when the recovery scope is the complete MySQL instance on MySQL 8.4. In every case, schedule around conflicting DDL and confirm the result with a real restore.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.