Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Duplicate a MySQL Database on Linux

Use mysqldump to clone a MySQL database on the same Linux host or move it to another server. This guide covers renaming, consistency, object coverage, verification, failures, and when physical backup or MySQL Shell is a better fit.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On the same Linux host, duplicate a MySQL database with a logical dump: run mysqldump db1 > dump.sql, create the destination with mysqladmin create db2, then load it with mysql db2 < dump.sql. If the copy is going to another server, either include database-creation statements with mysqldump --databases db1 and load the file normally, or omit that option, create the destination database yourself, and load the dump into the name you choose.

What “duplicate a database” means

A MySQL duplication normally means creating a logical copy of SQL objects and table rows. The result can be used for development, DBA work, testing, or a controlled move to another Linux server. Oracle describes this use case as cloning databases or producing slight variations of an existing database for testing.

As an Amazon Associate I earn from qualifying purchases.

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.

A logical dump is a text file containing SQL statements. MySQL reads those statements on the destination and reconstructs the selected objects and data. This is portable and easy to rename, but it is not the same as copying the server’s underlying data files. A database copy also does not automatically make the destination a complete copy of the source server’s accounts, privileges, configuration, replication state, or other databases.

Before you start

  • Confirm the source database name and the destination name. In the examples below, the source is db1 and the destination is db2.
  • Run the commands on a Linux account that can connect to MySQL, read the objects being dumped, create or load the destination database, and write the dump file where you place it.
  • Check free disk space for the dump and for the restored tables. A dump can be large even when the live database appears smaller because the file contains SQL text and metadata.
  • Decide whether the copy is for the same host or another server, and whether it should keep the original name.
  • Decide which objects and security data must be transferred: tables and rows, views, triggers, stored procedures and functions, events, users, and grants.
  • Choose a maintenance window or consistency plan. A dump taken while the application is writing may need different handling from a quiet development database.

Duplicate a database on the same Linux host

The basic three-command method

Use Oracle MySQL’s straightforward sequence when the destination is on the same server:

#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.
mysqldump db1 > dump.sql
mysqladmin create db2
mysql db2 < dump.sql
  1. mysqldump db1 > dump.sql reads db1 and writes a logical SQL dump to dump.sql. The shell redirection creates or overwrites that file in the current directory.
  2. mysqladmin create db2 creates an empty database named db2.
  3. mysql db2 < dump.sql starts a MySQL client session connected to db2 and feeds the dump into it.

After the third command completes without an error, the destination contains the objects and rows represented in the dump. The source database is not modified by this sequence.

Supply the account and password explicitly

When the MySQL account, password prompt, or connection context should be explicit, use the equivalent form:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysqldump -u USER -p --single-transaction db1 > dump.sql
mysqladmin -u USER -p create db2
mysql -u USER -p db2 < dump.sql

Each -p normally prompts for the password rather than putting it in the shell command line. Replace USER with an account authorized for the operation. If source and destination use different connection parameters, specify the appropriate host, port, socket, or account for each command instead of assuming they are identical.

Why the destination name matters

Do not add --databases to the same-host command when you want db1 copied into a differently named db2. That option writes a USE db1 statement into the dump. When the file is loaded with mysql db2 < dump.sql, the embedded USE db1 can switch the session back to the source name and defeat the rename.

For a same-name copy, an embedded database selection may be useful, but the destination must then be planned around that name. For a renamed copy, omit --databases, create the destination explicitly, and load into it as shown above.

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

Keeping the dump consistent while MySQL is running

When to use --single-transaction

--single-transaction is suitable for many InnoDB workloads when you need a transaction-consistent logical snapshot without stopping ordinary application activity. The practical command is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysqldump -u USER -p --single-transaction db1 > dump.sql

It does not remove the need to review the workload. Confirm which tables and objects are being copied, how much write activity occurs during the dump, and whether the application performs schema changes at the same time.

DDL that can invalidate the snapshot

DDL operations during a single-transaction dump are an operational hazard. Statements such as ALTER TABLE, CREATE TABLE, DROP TABLE, RENAME TABLE, and TRUNCATE TABLE can make the read inconsistent or cause the dump to fail. Schedule those changes outside the dump window, pause the deployment that could issue them, or choose a locking and backup approach appropriate to the workload.

For production data, document the consistency decision before starting: identify the snapshot window, the expected write activity, and the response if the dump exits with an error. Treat a successfully created file as a candidate backup until its contents and restore have been checked.

Copy a MySQL database to another Linux server

Method 1: include database-creation statements

If the target should receive the database under the same name, include the database definition in the dump:

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)
# source server
mysqldump --databases db1 > dump.sql

# copy dump.sql to the target server

# target server
mysql < dump.sql

The dump contains statements that create or select db1, so the target-side client does not need a separate database-creation command. Transfer dump.sql by the file-transfer method approved for your environment, then run the load on the target host.

Method 2: choose a different name on the target

When the target database must be called db2, omit --databases and create the destination explicitly:

# source server
mysqldump db1 > dump.sql

# copy dump.sql to the target server

# target server
mysqladmin create db2
mysql db2 < dump.sql

This is the cross-server equivalent of the same-host rename procedure. It avoids an embedded USE db1 statement taking precedence over the target name.

Move the file safely

Keep the source and target steps distinct. Finish the dump, confirm the file exists and has a plausible size, transfer it using your organization’s secure transport, and only then start the target load. Preserve the original dump until verification is complete and the rollback decision has been made.

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

If the transfer is interrupted, do not assume a partial file can be loaded safely. Re-transfer it, compare checksums if your process supports that, and record which source dump was used for the restore.

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

What a logical dump does and does not copy

Item What to expect Decision to make
Tables and table rows These are the primary contents reconstructed by replaying the SQL dump. Confirm all required databases and tables were selected.
Views View definitions may be represented as SQL objects in the dump. Check that dependent objects and definers are valid on the target.
Triggers Trigger definitions can be included as objects. Verify that triggers are present and behave with the target schema.
Stored procedures and functions Routine definitions require explicit attention during planning. Decide which routines belong in the copy and validate their dependencies.
Events Scheduled event definitions are a separate object category. Decide whether events should be restored active, inactive, or not at all.
Users and grants A database dump is not automatically a complete privilege migration. Handle accounts and grants as a separate server-administration task.
Server configuration and other databases These are outside a single database’s logical contents. Plan configuration, plugins, replication, and other schemas separately.

Grant tables live in MySQL’s mysql database. Copying an application schema alone therefore does not reproduce the source server’s complete account and privilege setup. Recreate or migrate security data deliberately, and review account hosts, authentication, and least-privilege requirements on the target rather than blindly treating the destination as an identical server.

Verify the duplicate before using it

Do not stop at a successful exit status. Verification should compare the source and destination in the context of your application.

  1. Check database and table presence. Connect to the destination and list the expected schema objects. Missing tables often indicate that the wrong database name was selected or that the dump stopped partway through.
  2. Compare table counts. Count the tables on both sides and investigate any difference before allowing application traffic to use the copy.
  3. Compare representative row counts. Select row counts from critical, large, and recently changing tables. A matching table list with a short row count can reveal an incomplete load.
  4. Inspect views, routines, triggers, and events. Confirm each required object exists and references the correct schema, account, and dependencies.
  5. Check character sets and collations. Compare database, table, and column settings where text sorting or comparison affects the application.
  6. Test application connectivity. Use the destination credentials and connection settings in a controlled test. Check reads, writes, transactions, background jobs, and any code that relies on scheduled events.
  7. Review errors and warnings. Keep the client output and server log relevant to the load. Resolve permission, syntax, missing-object, and constraint errors instead of accepting a partially restored database.

Verification is an environment-specific operational check; it is not established merely because the dump command produced a file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failures and how to recover

The load goes into the wrong database

Check whether the dump was created with --databases. If it contains USE db1, loading it while naming db2 may still target db1. Recreate the dump without --databases, create the intended destination, and load it into that database.

The destination database does not exist

The command mysql db2 < dump.sql cannot load into a database that has not been created. Run mysqladmin create db2 with an account allowed to create it, or use the cross-server form that includes database-creation statements when retaining the source name.

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.

Authentication or permission errors occur

Verify the account, host, socket or TCP endpoint, and password prompt used by each command. The account must be able to read the source objects and perform the destination operations. If the dump contains routines, views, triggers, or events, permissions and definers for those objects may require separate review.

The dump fails during active schema changes

Look for concurrent ALTER TABLE, CREATE TABLE, DROP TABLE, RENAME TABLE, or TRUNCATE TABLE operations. Reschedule the dump outside the DDL window, coordinate with the deployment owner, or choose a method whose locking and consistency behavior matches the workload.

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

The target loads only part of the file

Check the client’s final error, the server log, available disk space, and the dump file itself. Do not point the application at a partial copy. Correct the underlying issue, recreate the destination if necessary, rerun the load from a known-good dump, and repeat the verification checklist.

Logical dump versus physical backup

Consideration Logical SQL dump Physical backup
Portability SQL can be transferred between compatible Linux installations and can be loaded under a different database name when the dump is created without database-selection statements. Data files are tied more closely to the server’s storage format and backup tooling.
Object-level selection Useful when selecting databases or categories of objects for a development or test copy. Generally aimed at preserving a larger server or data-file set.
Restore speed at large scale Requires parsing and executing SQL, so large restores can be time-consuming. Oracle notes that physical backup is more appropriate for large-scale backup and restore because it preserves data files in their original format for faster restoration.
Renaming a database Straightforward when the dump omits --databases and the target is created explicitly. Usually requires a storage- and server-specific procedure rather than simply changing a client command.
Best fit Portable copies, development clones, DBA work, and slight variations for testing. Very large backup and restore workloads where restore time and data-file handling dominate.

Choose based on scope, naming, object coverage, consistency requirements, downtime, and scale. A logical dump is not automatically the fastest or safest option for every production-sized dataset.

Where mysqlpump fits today

mysqlpump can produce logical backups, parallelize work, and include or exclude selected databases and object types. However, Oracle marks it deprecated as of MySQL 8.0.34 and directs current workflows toward mysqldump and MySQL Shell dump utilities.

For a small, portable duplicate with a clear rename, use the simple mysqldump procedure. For larger transfers that benefit from parallel dump or load work, evaluate the current MySQL Shell dump and load utilities against your MySQL version, network, storage, and restore requirements. Do not introduce a deprecated utility into a new operating procedure without a specific compatibility reason.

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

A practical decision guide

Your situation Recommended starting point Important qualification
Same host, new database name mysqldump db1 > dump.sql, create db2, then load into db2. Do not use --databases, because its embedded USE db1 can override the target.
Another host, same database name Use mysqldump --databases db1 > dump.sql, transfer the file, then run mysql < dump.sql on the target. Coordinate secure transfer and verify the restored objects.
Another host, different database name Dump without --databases, create the destination on the target, and load into that name. Review routines, events, triggers, views, and definers separately.
Active InnoDB workload Consider --single-transaction. Concurrent DDL can make the dump inconsistent or cause failure; review writes and schema changes first.
Very large backup or restore Evaluate physical backup or MySQL Shell dump/load utilities. Physical backup favors large-scale restore speed but is less like a portable, renameable SQL copy.
Privilege or server migration Plan a separate account, grant, and server-configuration migration. A single application database dump is not a complete server identity.

Repeatable runbook

  1. Write down the source host, source database, target host, target database, MySQL version, and required object categories.
  2. Choose a consistency window and prevent conflicting DDL if using --single-transaction.
  3. Create the dump with or without --databases according to whether the target name must change.
  4. Check that the dump completed and retain its output and logs.
  5. Transfer the file securely when the target is remote.
  6. Create the destination database when the dump does not contain its creation statement.
  7. Load the file and stop on errors rather than accepting an incomplete copy.
  8. Verify tables, representative rows, programmable objects, character sets and collations, and application connectivity.
  9. Handle users, grants, and server configuration separately.
  10. Keep the source dump and verification record until the destination has been accepted and the rollback period has ended.

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.