October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Cupertino desk4 min

How to Back Up and Restore a Local MySQL Database on macOS

Back up a local MySQL database on macOS with mysqldump, restore its .sql file with mysql, and verify the recovery before relying on it.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a small or moderate local MySQL database, use mysqldump to save a logical SQL backup and the mysql client to restore it. The dump is written to the Mac running the command; before importing, check that the client is pointed at the intended server and database.

Back up one database from Terminal

Open Terminal and run the command from an account that can read the database. Replace db_name with the database name and choose a destination you can find and protect:

As an Amazon Associate I earn from qualifying purchases.

mysqldump db_name > backup-file.sql

This basic MySQL 8.0 example writes backup-file.sql in Terminal’s current working directory. To choose a different location, use a full or relative path, for example ~/Documents/backup-file.sql. The resulting file contains SQL statements for recreating database objects and table contents; it is a logical export, not a copy of every MySQL server file. MySQL 8.0: mysqldump describes the utility and its options.

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

If MySQL prompts for a password, enter it at the prompt rather than putting it directly in the command, where it could be retained in shell history. Authentication methods differ by local installation and account configuration, so use the method configured for your MySQL account.

#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Back up all databases instead

The one-database command does not export every database. For a full logical dump of all databases, MySQL documents this separate command:

mysqldump --all-databases > all_databases.sql

Choose the scope deliberately: an all-databases dump can include more data than you intend to move or restore.

Find mysqldump if Terminal cannot

If Terminal reports command not found, the MySQL utilities may not be on your shell’s PATH, or the command-line tools may not be installed. MySQL’s macOS documentation covers both the native package installer and compressed TAR archive installation; their utility locations can differ. Use the mysqldump and mysql executables belonging to your installation, and resolve their location or update your PATH as appropriate rather than assuming one universal macOS path. See MySQL 8.0: Installing MySQL on macOS.

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

The server must also be running and reachable for a dump or import. If it is stopped, start it using the service-management method for your installation; the MySQL macOS installation guide includes launch-daemon information.

Rank #2
YOTUO 500GB External Hard Drive, Portable Storage Expansion HDD, USB 3.0 & USB-C for PC, Mac, Desktop, Laptop, Smartphone, PS4, Xbox One, Xbox 360, Office & Game Black
  • 【Versatile Storage Expansion – For Gaming, Work & Everyday Use】 Running out of space on your PS5 or Xbox Series X/S? This external hard drive lets you store and play PS4 / Xbox One games directly, instantly freeing up your console’s internal storage for next‑gen titles. At the same time, it handles work file backups, media libraries, and cross‑device data transfers with ease. One drive, all your needs. *(Note: PS5 / Xbox Series X|S games cannot be run or stored directly from the external hard drive. However, by offloading your PS4 / Xbox One games, you can free up valuable space for newer titles.)*
  • 【Patented Silicone Sleeve – Data Protection You Can Count On】 Worried about drops? We’ve got you covered. The patented built‑in silicone sleeve acts like a shock‑absorbing armor, cushioning your drive against bumps and falls. Whether it’s important work documents, precious family photos, or hard‑earned game saves, your data deserves this level of protection.
  • 【Plug & Play, Compatible with Computers & Consoles】 No complicated setup—just plug in and go. Works seamlessly with Windows, Mac, and Linux computers, as well as PS4, PS5, Xbox One, and Xbox Series X/S. Process files at the office, back up data at home, or enjoy gaming in your downtime—one drive handles all your devices, simply and hassle‑free.
  • 【USB 3.0 Ultra‑Fast Transfer – No More Waiting】 Tired of watching progress bars crawl? With USB 3.0 speeds up to 5Gbps, large files transfer in seconds. Whether you’re moving work documents, transferring hundreds of gigs of games, or backing up a year’s worth of photos, you get more done in less time.
  • 【Sleek, Lightweight, and Ready to Go】 Weighing just 0.16 kg—lighter than a can of soda—this compact drive features a stylish mirror‑and‑frosted finish. Toss it in your bag and go, whether you’re heading to the office, visiting a friend for a gaming session, or giving a presentation on the road.

Improve consistency for InnoDB tables

For a database whose tables are all InnoDB, --single-transaction can produce an online dump without locking all tables for the entire operation. For example, MySQL’s backup-policy guidance includes a form that also records source-data metadata:

mysqldump --single-transaction --source-data=2 db_name > backup-file.sql

Use this option only with an understanding of the database’s engines and concurrent activity. It is not a universal consistency guarantee: nontransactional tables and concurrent DDL operations need care. The documented combination with source-data metadata also has a brief initial lock behavior. Check the manual for the installed client version and the options it supports before relying on this exact form. See MySQL 8.0: Establishing a Backup Policy.

A logical dump can be made at server, database, or table scope and works across storage engines, but it does not include server logs, configuration files, or other files outside the logical database contents. If point-in-time recovery is needed, a dump alone is insufficient: that workflow also depends on binary logs and server configuration.

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

Restore a .sql file into MySQL

First confirm the destination server and database. The import sends the file’s SQL statements to the database named in the command; choosing the wrong target can change data on that server.

Rank #3
YOTUO 1TB External Hard Drive, Portable Storage Expansion HDD, USB 3.0 & USB-C for PC, Mac, Desktop, Laptop, Smartphone, PS4, Xbox One, Xbox 360, Office & Game, Black
  • 【Versatile Storage Expansion – For Gaming, Work & Everyday Use】 Running out of space on your PS5 or Xbox Series X/S? This external hard drive lets you store and play PS4 / Xbox One games directly, instantly freeing up your console’s internal storage for next‑gen titles. At the same time, it handles work file backups, media libraries, and cross‑device data transfers with ease. One drive, all your needs. *(Note: PS5 / Xbox Series X|S games cannot be run or stored directly from the external hard drive. However, by offloading your PS4 / Xbox One games, you can free up valuable space for newer titles.)*
  • 【Patented Silicone Sleeve – Data Protection You Can Count On】 Worried about drops? We’ve got you covered. The patented built‑in silicone sleeve acts like a shock‑absorbing armor, cushioning your drive against bumps and falls. Whether it’s important work documents, precious family photos, or hard‑earned game saves, your data deserves this level of protection.
  • 【Plug & Play, Compatible with Computers & Consoles】 No complicated setup—just plug in and go. Works seamlessly with Windows, Mac, and Linux computers, as well as PS4, PS5, Xbox One, and Xbox Series X/S. Process files at the office, back up data at home, or enjoy gaming in your downtime—one drive handles all your devices, simply and hassle‑free.
  • 【USB 3.0 Ultra‑Fast Transfer – No More Waiting】 Tired of watching progress bars crawl? With USB 3.0 speeds up to 5Gbps, large files transfer in seconds. Whether you’re moving work documents, transferring hundreds of gigs of games, or backing up a year’s worth of photos, you get more done in less time.
  • 【Sleek, Lightweight, and Ready to Go】 Weighing just 0.16 kg—lighter than a can of soda—this compact drive features a stylish mirror‑and‑frosted finish. Toss it in your bag and go, whether you’re heading to the office, visiting a friend for a gaming session, or giving a presentation on the road.
  1. If the destination database does not exist, create it deliberately using an account and setup method appropriate for your local server. The exact creation and authentication steps vary by MySQL version and account configuration.

  2. In Terminal, run the MySQL client with the intended database name and the path to the dump:

    mysql db_name < backup-file.sql

    For a file elsewhere, replace backup-file.sql with its path, such as ~/Documents/backup-file.sql.

    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.
  3. Wait for the command to finish and check for errors. Confirm that expected tables and data are present in the destination.

    Rank #4
    WD 5TB My Passport Ultra for Mac Silver, Portable External Hard Drive, backup software with defense against ransomware, and password protection, USB-C and USB 3.1 - WDBPMV0050BSL-WESN
    • USB-C and USB 3.1 compatible.Specific uses: Business, personal
    • Innovative style with refined metal cover
    • Password protection with 256-bit AES hardware encryption
    • Formatted for Mac

The restore pattern above is documented in MySQL 8.0: mysqldump. A dump’s contents and options affect what statements it runs, so do not treat importing into an existing database as a harmless merge. Test an unfamiliar dump in a separate database before using it on data you need to keep.

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

Verify the backup and keep a recoverable copy

A successful command exit and a nonempty SQL file are useful initial checks, but they do not prove that the dump can be restored correctly. The practical verification is a test import into a separate database, followed by inspection of expected tables and representative rows.

When a logical dump is not enough

A logical dump is portable, inspectable, and convenient for ordinary local development databases. Its SQL statements must be replayed during restore, which can be slow for substantial datasets; MySQL does not position mysqldump as a fast, scalable solution for large volumes.

Physical backups copy underlying data files. MySQL describes them as faster to make and restore, with less portability and more requirements for handling server files and state correctly. Do not copy a live data directory casually and assume it is a consistent backup. For large, important datasets or faster recovery needs, consult the version-appropriate MySQL physical-backup guidance: MySQL 8.0: Backup and Recovery Types.

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

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 from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

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.