Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober 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 PC×
Skip to content
World desk13 min

How to Export and Import a MySQL Database via SSH

A practical, security-conscious guide to exporting and importing MySQL over SSH, including compressed files, direct pipelines, live InnoDB databases, destination preparation, validation, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable pattern is to create a logical SQL dump with mysqldump, move it through an encrypted SSH connection, and replay it with the mysql client. You can copy a compressed dump as a file or stream the dump directly from the source server to the destination. The destination database and an account with the required privileges must be ready first.

What an SSH-based MySQL migration actually does

mysqldump does not copy MySQL’s internal data files. It reads object definitions and table data, then writes SQL statements that can recreate them. Oracle describes the utility as producing “a set of SQL statements that can be executed to reproduce the original database object definitions and table data.” The resulting file is a logical backup: portable and easy to inspect, but generally slower to restore than a physical backup at very large scale.

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.

SSH supplies the encrypted remote shell or transport. It does not replace MySQL authentication. You still need a MySQL account on the source for the dump and an account on the destination for the import. The SSH account and the MySQL account can be different users.

There are two practical data paths:

  • File workflow: create a .sql or .sql.gz file, copy it with scp, then import it.
  • Stream workflow: run mysqldump over SSH and pipe its output into mysql on the destination, without storing the complete dump there first.

Both approaches keep MySQL off the public internet. Do not expose port 3306 merely to move a backup when SSH access is available.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Pre-flight checks before you dump anything

A few minutes of checking prevents most failed migrations. Confirm each item on both sides where applicable.

  • SSH access: test that you can log in to the source and destination hosts, and that the SSH users can read the chosen transfer directory.
  • MySQL reachability: verify that the MySQL client can connect locally or through the host’s approved socket or network endpoint.
  • Versions: record the MySQL client and server versions. Differences can affect supported options, authentication plugins, SQL modes, and object definitions.
  • Database and account names: identify the source database, the destination name, and which MySQL account will perform each operation.
  • Privileges: the dumping account normally needs SELECT on dumped tables, SHOW VIEW for views, and TRIGGER for triggers. Exact requirements vary with the options used and the server version.
  • Disk space: allow room for the uncompressed SQL, any compressed copy, temporary files, and the destination’s data growth. A compressed archive can expand considerably during import.
  • Service type: determine whether the destination is self-managed or provider-managed. Managed services often restrict system schemas, user creation, or server-level options.
  • Application timing: decide whether writes must be paused, drained, or otherwise coordinated. A dump is not a substitute for a migration cutover plan.

Keep passwords out of shell history and process listings where possible. Use the interactive prompt produced by -p (without placing the password after it), or use a protected MySQL option file with appropriate filesystem permissions.

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.

Choose a transfer pattern

Pattern Best fit Disk use Operational considerations
Compressed file plus scp Repeatable migrations, audit trails, or a backup you may need to retry Requires space for the archive and usually a copy on each side You can verify the file, resume the import later, and retain the archive according to your backup policy
Uncompressed file plus scp Small databases or environments where compression is unnecessary Largest transfer footprint Simplest to inspect, but slower over a constrained link
SSH pipeline A one-time move when the destination has little spare disk No complete dump file on the destination A broken connection or SQL error requires rerunning the pipeline unless you separately capture the output

Compression reduces transfer bytes, not the amount of SQL that MySQL must execute. For a large or heavily written installation, plan restore time and rollback separately from network time.

Export the source database

Basic SQL export

Log in to the source host over SSH, change to a directory with sufficient space, and run:

mysqldump -u DB_USER -p DB_NAME > DB_NAME.sql

The client prompts for the MySQL password. The shell redirect creates the file as the SSH user, so that user must be able to write to the current directory. Check the command’s exit status before treating the file as a valid backup.

Exporting a live, predominantly InnoDB database

For an InnoDB-heavy database that remains online, this commonly appropriate pattern requests a consistent transactional snapshot while reading rows in a streaming-friendly way:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
mysqldump --single-transaction --quick --routines --triggers --events 
  -u DB_USER -p DB_NAME | gzip > DB_NAME.sql.gz
  • --single-transaction starts a transaction-based snapshot for transactional tables such as InnoDB, avoiding the broad table locks associated with a locking dump in many cases.
  • --quick reads rows incrementally instead of loading an entire table into client memory.
  • --routines includes stored procedures and functions.
  • --triggers includes triggers (and is important when triggers are part of the application behavior).
  • --events includes scheduled events.
  • gzip compresses the SQL stream before it is written to disk.

--single-transaction is not a universal consistency guarantee. Nontransactional tables do not receive the same snapshot protection, and concurrent schema changes can affect a dump. Do not perform schema-changing DDL while the export runs unless your application and backup design explicitly account for it. If the database contains important MyISAM or other nontransactional tables, coordinate a write pause or another consistency method.

Decide whether to include database-selection statements

Adding --databases changes the output. For example:

mysqldump --single-transaction --databases DB_NAME > DB_NAME.sql

A dump made with --databases DB_NAME contains CREATE DATABASE and USE DB_NAME statements. That is convenient when restoring the same name, but the embedded USE can defeat an attempted rename. A dump made without --databases contains the objects and data without selecting the database for you; it is usually more convenient when the destination name will differ.

What the dumping account must be allowed to read

The account must be able to read every object you ask the utility to export. The MySQL manual identifies SELECT for table data, SHOW VIEW for views, and TRIGGER for triggers among the relevant privileges. Additional options and server versions can introduce other requirements. If the dump reports an access error, identify the object named in the error and grant the narrowest missing permission rather than switching to an unrestricted account automatically.

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

Move the dump through SSH

Copy a compressed archive with scp

From the source host, copy the archive to a directory on the destination:

scp DB_NAME.sql.gz DEST_USER@DEST_HOST:/path/to/transfer/

Use a destination directory that the SSH account can write and that has enough free space. If the hosts require a nondefault SSH port or key, supply the corresponding SSH options through your normal configuration or the scp command. After copying, verify the file size and, when the migration warrants stronger assurance, compare a checksum calculated independently on both hosts.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Stream directly from source to destination

When both SSH accounts and MySQL endpoints are ready, you can avoid creating a complete archive on the destination:

ssh SRC_USER@SRC_HOST 
  'mysqldump --single-transaction --quick -u DB_USER -p DB_NAME' 
  | ssh DEST_USER@DEST_HOST 
  'mysql -u DB_USER -p DB_NAME'

The first SSH session runs the dump on the source; the second runs the MySQL client on the destination. Each -p prompts for the password in the corresponding remote session. Test this with a small nonproduction database first, because an authentication failure, dropped SSH connection, or SQL error interrupts the pipeline and leaves no complete file to inspect.

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

If compression is useful in the pipeline, compress on the source and decompress on the destination:

ssh SRC_USER@SRC_HOST 
  'mysqldump --single-transaction --quick -u DB_USER -p DB_NAME | gzip' 
  | ssh DEST_USER@DEST_HOST 
  'gunzip -c | mysql -u DB_USER -p DB_NAME'

Do not combine a pipeline with an assumed destination database name until you have checked whether the dump contains CREATE DATABASE and USE statements.

Prepare the destination database and account

Self-managed MySQL

Create the destination database and a dedicated account before importing a dump that was made without --databases. An administrator can use statements such as:

CREATE DATABASE target_db;
CREATE USER 'import_user'@'localhost' IDENTIFIED BY 'use-a-secret-managed-outside-history';
GRANT ALL PRIVILEGES ON target_db.* TO 'import_user'@'localhost';

Use the least privilege compatible with the objects and import process. A temporary migration account may need broader rights than the application’s runtime account, especially for routines, triggers, or events; reduce or remove those rights after the migration if they are no longer needed. The exact host part of the account, authentication method, and grant syntax should match your MySQL version and network design.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Provider-managed MySQL

Managed services can prohibit importing system schemas, creating provider-owned users, or changing server settings. They may require provider-specific flags or an administrative workflow. Follow the service’s documented import restrictions and omit system databases and accounts that the provider controls. A dump that succeeds on a self-managed server can fail when it contains unsupported users, privileges, or system objects.

Import the SQL dump

Import a dump that includes --databases

If the archive was produced with --databases DB_NAME, let its embedded CREATE DATABASE and USE DB_NAME statements select the database:

gunzip -c DB_NAME.sql.gz | mysql -u DB_USER -p

Do not append a different database name to this command when you intend to rename the database. The dump’s own USE DB_NAME statement selects the original name, and the import may populate that database instead of the name you supplied.

Import a dump without --databases

Create or select the destination database explicitly:

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

For a compressed file, stream decompression into the client:

gunzip -c DB_NAME.sql.gz | mysql -u DB_USER -p DB_NAME

This form is the normal choice when restoring under a new database name. The MySQL account must have permission to create the dumped objects in that target schema.

Import order and application behavior

Stop or place the application in maintenance mode if writes during the restore could create inconsistent results. The SQL file usually contains statements that establish tables and then load data; routines, triggers, views, and events are recreated according to the dump’s contents. If application code expects a specific SQL mode, character set, collation, or time-zone configuration, check those settings on the destination before declaring the migration complete.

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

Validate the result before cutover

A successful process exit proves only that the client did not report an error. Validate the restored database as an independent step.

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.
  1. Review output and logs. Capture the import output, check the client exit status, and inspect the MySQL server error log for warnings or failed object creation.
  2. Check schema shape. Confirm that expected tables, indexes, views, stored procedures, functions, triggers, and scheduled events exist.
  3. Check data volume. Compare expected row counts, or sample representative tables when a full count is too expensive. For higher-assurance migrations, compare checksums or another independently defined reconciliation measure.
  4. Test application reads and writes. Exercise a representative login, read, create, update, and background-job path against the destination. Verify that connections use the intended database name.
  5. Plan the cutover. Freeze or replicate final writes, perform a final delta strategy if one exists, switch the application connection, and retain the source until the rollback window expires.

Validation is especially important when moving between different MySQL versions or between self-managed and provider-managed environments, where unsupported objects may be omitted or transformed.

Common failures and precise fixes

Symptom Likely cause Fix
Access denied during dump The MySQL account lacks a required object privilege, or its host restriction does not match the connection. Verify the account and connection host. Grant only the missing permissions, such as SELECT, SHOW VIEW, or TRIGGER, then rerun the dump.
Access denied during import The destination account cannot create or alter the objects in the target schema. Use a migration account with the required schema-level privileges, or adjust grants under administrator control.
Unknown database The dump was created without --databases, and the target schema does not exist. Create the destination database first, then import with its name after the mysql command.
Data appears under the old name after a rename The dump contains USE old_name because it was made with --databases. Restore into the embedded name, or regenerate the dump without --databases and import it while naming the new schema.
Dump is inconsistent while the application stayed online Nontransactional tables or concurrent schema-changing DDL were not coordinated. Use a maintenance window or a consistency method appropriate to those tables; do not rely on --single-transaction for nontransactional data.
Restore is extremely slow Logical SQL replay performs row and index work through the server and can be expensive for large installations. Schedule adequate downtime, tune the restore under your server’s documented limits, or evaluate a physical backup method for very large databases.
Import fails only on a managed service The archive contains system schemas, users, privileges, or options the provider controls. Remove provider-owned objects and follow the service’s supported import procedure and flags.
Pipeline stops partway through An SSH session, password prompt, network path, or MySQL client exited with an error. Capture stderr, test source dump and destination import separately, then rerun from a retained archive when possible.

Logical dump versus physical backup

A logical dump is the right default when you need a portable SQL representation, a selective database migration, or a move between compatible MySQL environments. It can be inspected, filtered, compressed, and restored under another schema name when created without --databases.

Its trade-offs are CPU and I/O during export, potentially large SQL text, and restore time that grows with the amount of data and index work. For very large installations, MySQL documentation recommends considering physical backup tooling. Physical methods copy database files or storage-level structures and can restore faster, but they are more dependent on server version, storage layout, operating system, and provider compatibility. They are not a drop-in replacement for a portable SQL file.

Decision axis Logical mysqldump Physical backup
Downtime and locking --single-transaction can reduce disruption for transactional InnoDB tables, but nontransactional tables and DDL need separate planning. Depends on the physical tool and storage design; coordinate according to that tool’s consistency requirements.
Consistency model SQL snapshot semantics, with limitations outside transactional tables. Storage-level consistency designed for the selected physical method.
Transfer size Often compressible text; size depends on SQL representation and compression. Reflects physical data and index files and may be large.
Restore speed Can be slow because SQL statements are executed and indexes rebuilt or updated. Often preferable for very large installations when source and destination are compatible.
Portability Generally easier to move between compatible MySQL versions and environments, subject to SQL and object compatibility. More tightly coupled to server and storage compatibility.
Users and privileges Database objects can be dumped, but provider-owned users and system schemas may be restricted. May include server-level state that is unsuitable for a managed destination.

Security and reliability practices

  • Use SSH keys or your organization’s approved SSH authentication rather than sharing passwords between operators.
  • Keep dump files readable only by the account and group that need them; SQL archives can contain personal data and credentials stored in tables.
  • Use an option file or an interactive prompt instead of putting a MySQL password directly in the command line.
  • Transfer through a private network or SSH bastion when available; do not open MySQL to the public internet for convenience.
  • Retain the original archive until validation and the rollback window are complete, then apply your retention and deletion policy.
  • Record source and destination versions, database names, dump options, timestamps, and validation results so the migration can be repeated.
  • Test the exact procedure on a staging copy before a production cutover, including the managed-service restrictions that apply to the real destination.

A repeatable migration runbook

  1. Record MySQL versions, source and destination names, SSH endpoints, privileges, storage capacity, and whether either side is provider-managed.
  2. Test SSH and MySQL logins independently. Confirm the dump account can read required objects and the import account can write the target schema.
  3. Choose a file or stream workflow. Prefer a retained compressed file when you need auditability, retry capability, or a rollback artifact.
  4. Coordinate application writes and schema changes. For an InnoDB-heavy live database, use --single-transaction --quick and include routines, triggers, and events when they are part of the application.
  5. Create the destination database and account when the dump does not contain database-creation statements, or verify that the managed service’s import process will create them.
  6. Export, check the command status, and record the resulting file size or pipeline status.
  7. Copy with scp or stream through SSH. Verify a retained archive with a checksum when the migration’s assurance requirements call for it.
  8. Import using the command that matches the dump’s --databases choice. Never assume a supplied target name overrides an embedded USE statement.
  9. Inspect logs and object counts, run representative application checks, and reconcile important data.
  10. Perform the controlled cutover, retain the source and archive for the agreed rollback period, and remove temporary privileges when they are no longer needed.

When SSH access is unavailable

This procedure depends on shell access to at least the host that runs the dump and, for the file workflow, the host that receives it. If your hosting plan exposes only a web panel or database console, use that provider’s supported export and import mechanism or move to an SSH-enabled environment. The same logical principles still apply: create a dump, transfer it over an encrypted channel, prepare the target schema and account, import, and validate.

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.