Halloween 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 NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk14 min

How to Import a Large MySQL Database on a VPS (CLI, Compressed Dumps, and Faster Alternatives)

A practical guide to restoring large MySQL databases on a VPS without browser timeouts, including SQL and compressed dumps, tab-delimited loads, physical backups, sizing, compatibility, and validation.

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.

Import a large MySQL dump on a VPS with the command-line mysql client, not a browser upload. Copy the dump to the server, determine whether it contains CREATE DATABASE/USE statements, then run the matching command inside a persistent tmux or screen session while logging output. For a compressed dump, stream decompression directly into MySQL to avoid creating a second uncompressed copy. After the command exits, verify errors, schemas, tables, and representative row counts.

The right procedure depends on the dump format, available disk space, storage engines, and acceptable downtime. This guide covers SQL dumps, compressed SQL, tab-delimited exports, and physical backups, including the failure modes that commonly make a VPS restore appear to hang or fail.

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.

Choose the restore method before you start

A logical SQL restore replays statements one by one: table definitions, indexes, triggers, and INSERT operations. It is portable, but the target server must parse every statement, write data and redo/undo information, and build or maintain indexes. MySQL documentation identifies the restore stage as the most time-consuming part of handling large data sets, so a multi-gigabyte file can take considerably longer to load than to copy.

Use this decision table to select a workflow. No universal import-time estimate exists; measure with a representative restore on the target VPS instead of promising an ETA based only on file size.

Format Disk-space profile Downtime and speed Parallel work Engine and compatibility considerations
Single SQL file Requires the dump plus MySQL’s data, temporary, redo/undo, and index-creation space. A second copy is not required. Usually the simplest and most portable logical restore, but execution of individual statements can be slow. Downtime is workload-dependent and not stated as a universal figure. A single client process normally executes statements serially. Works across many server setups when SQL syntax, character sets, collations, SQL mode, and object definitions are compatible.
Compressed SQL stream Stores the compressed file and MySQL’s working space; streaming avoids writing an additional uncompressed dump. Transfer is smaller and disk pressure is lower, while decompression adds CPU work. Restore time remains dependent on SQL execution and storage I/O. The ordinary pipeline is one decompressor feeding one client. Has the same logical-dump compatibility requirements as an uncompressed SQL file.
Tab-delimited export Needs the transferred dump directory, table data files, SQL definition files, and database working space. MySQL documents this approach as much faster than simply using mysqldump for large tables. Downtime depends on table size and the chosen load order. Separate table files provide opportunities for carefully controlled parallel loading. Requires compatible table definitions and correct handling of delimiters, character sets, permissions, and local file access.
Physical backup Uses data files in their original format and needs a compatible target layout plus room for logs and recovery work. For large-scale backup and restore, MySQL says a physical backup is more appropriate because it can restore data files quickly. Downtime and throughput are environment-specific. The backup and recovery tooling may support parallel operations; capabilities depend on the product and engine. Compatibility is tighter: server version, storage engine, page format, operating system, and backup tooling must align.

For most one-off VPS migrations, start with a SQL or compressed SQL dump. Consider tab-delimited loading when very large tables make statement execution the bottleneck. For recurring, large-scale recovery, evaluate a physical-backup workflow; MySQL names MySQL Enterprise Backup for high-performance InnoDB and mixed-engine scenarios.

Check the VPS and the dump first

Confirm the client and server

Log in to the VPS and confirm that the MySQL client can reach the intended server and socket. Run mysql --version, then connect with the account that will perform the restore. The account needs permission to create or use the target database and to create the objects contained in the dump. If the dump contains routines, triggers, events, or views, the account also needs the corresponding privileges.

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

Keep the client and server versions reasonably aligned. A dump made by a newer release can contain syntax, collations, authentication behavior, or SQL features that an older server does not understand. Conversely, an older dump can activate compatibility modes or deprecated behavior on a newer server. Review the source and target versions before a production restore; there is no universal compatibility guarantee.

Measure space, not just the archive size

Check free space on the filesystem that holds the dump and the filesystem used by MySQL’s data directory. Plan for:

  • the original dump or compressed archive;
  • database files created by the restore;
  • temporary files used for sorting and index creation;
  • redo and undo growth while large transactions run;
  • binary logs or other audit logs generated during the import; and
  • headroom for normal VPS operation while the restore is running.

A compressed stream removes the need for a separate uncompressed archive, but it does not remove MySQL’s own data, temporary, or log requirements. If the target filesystem can fill during index creation or recovery, expand the volume or reduce other usage before starting.

Identify whether the dump selects a database

Inspect the beginning of the file without loading it. Look for statements such as CREATE DATABASE and USE. Dumps created with --all-databases or --databases normally contain those statements. A dump created for one database without those options generally contains table and data statements but does not select the database for you.

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

This distinction determines the command. Feeding a single-database dump to mysql without a database name can produce “No database selected” errors, while supplying a database name to an all-databases dump can prevent the dump from loading its intended databases.

Put the dump on the VPS

Transfer the file to a directory with enough space and permissions for the account that will run the client. Keeping the dump on the VPS avoids a browser request that can expire while a web server waits for the import to finish. It also keeps the restore path local to the MySQL client and server, reducing dependence on a long-running network upload.

Use your normal secure file-transfer method, such as an SSH-based copy or synchronization tool, and verify the resulting file size and checksum when the source system provides one. Do not place credentials in a world-readable directory. A temporary directory owned by the restore operator, with restrictive permissions, is preferable to a public web root.

Restore an uncompressed SQL dump

Dump containing database-selection statements

For a dump that includes CREATE DATABASE and USE statements, MySQL documents loading it as input to the client:

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

The client reads each statement from standard input. If authentication or a non-default socket is required, add the connection options used by your environment, for example a user, host, port, or socket. Avoid putting a production password directly in shell history; use an approved credentials file or let the client prompt securely.

Dump for one database without a USE statement

Create the destination database if it does not already exist, then name it on the client command line:

mysql -e 'CREATE DATABASE IF NOT EXISTS db1'
mysql db1 < dump.sql

The database’s default character set and collation should match the source unless you intentionally want a change. If the dump itself specifies table-level settings, those settings take precedence for the affected objects.

Run it in a persistent session and capture output

An SSH disconnect should not terminate a restore that may run for hours. Start tmux or screen, launch the command there, and detach from the session while it continues. Redirect standard output and standard error to a log file:

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.
mysql db1 < dump.sql > restore.log 2>&1

When you reconnect, resume the session and inspect the log. A command that returns to the shell is not automatically a successful restore: check its exit status immediately with echo $?. A zero status means the client completed without reporting an error; it does not prove that the source and target contain identical data, so perform the validation steps later in this guide.

Restore a compressed SQL dump without expanding it

When the dump is already compressed, stream decompression into the MySQL client:

gunzip < db_name.gz | mysql db_name

This is the documented cross-machine pattern for avoiding an additional uncompressed copy. The compressed archive remains on disk while decompressed SQL passes through the pipe. The destination still needs room for the database, temporary work, indexes, and logs.

Run the pipeline inside tmux or screen and log both stages:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
gunzip < db_name.gz | mysql db_name > restore.log 2>&1

Many shells report the exit status of only the last command in a pipeline. If decompression fails early, the MySQL client may simply receive end-of-file and return success. In a shell that supports it, enable pipeline failure reporting before starting:

set -o pipefail
gunzip < db_name.gz | mysql db_name > restore.log 2>&1
echo $?

Review the log for both decompression and SQL errors. A damaged archive must be replaced or repaired from a known-good copy; rerunning a partially applied logical dump can create duplicate rows or conflicting object definitions unless the restore is restarted from a clean database.

Make logical restores as efficient as the format allows

Choose dump options that reduce memory pressure

If you control dump creation, use --quick for large tables. It retrieves rows one at a time instead of buffering an entire result set in client memory. Extended multi-row INSERT statements reduce dump size and generally reload faster than one statement per row.

The --disable-keys option can help only with nonunique indexes on MyISAM tables. It does not provide the same benefit for unique indexes or for InnoDB tables, so do not assume it accelerates every schema.

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

Keep the storage path simple

Place the dump on the same VPS and, where practical, the same filesystem used by the client workflow. Avoid reading the archive over an unstable remote mount. Ensure the VPS disk can sustain the write rate of table data, index updates, temporary files, and redo logs at the same time. CPU may become the limit when a compressed stream is being decompressed, while storage latency commonly dominates statement-heavy restores.

Review packet and network settings

Large extended inserts must fit within the client and server packet limits. If the log reports packet-too-large errors, compare the client and server packet settings and raise them consistently within the memory and security limits of the VPS. Network settings matter when the client and server are on different hosts; a local client on the VPS removes that network hop but does not eliminate packet-size constraints.

Handle indexes and transaction growth deliberately

Index creation can consume substantial temporary space and I/O near the end of a table load. Redo and undo logs can also grow while large transactions are applied. Monitor free space and log growth during a test restore. Do not delete database files or force-kill MySQL to recover space; an interrupted transaction may require crash recovery, and removing files can make the database unusable.

Use the tab-delimited method for very large tables

MySQL documents a different logical-transfer format for cases where statement execution is the bottleneck. Create a dump directory with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysqldump --tab=DUMPDIR db_name

This produces SQL files containing table definitions and tab-delimited text files containing rows. Transfer the complete directory to the VPS, preserve file names and permissions, and create the destination database. Feed the SQL definition files to the client first so the tables exist:

for f in DUMPDIR/*.sql; do mysql db_name < "$f"; done

Then load the row files with:

mysqlimport db_name DUMPDIR/*.txt

For large tables, MySQL states that mysqldump plus mysqlimport can be much faster than simply loading a SQL dump. The files also make controlled parallelism possible: load independent tables concurrently only when the VPS has enough CPU, storage throughput, memory, and log capacity. Excessive parallel jobs can make the restore slower by forcing competing writes and index work.

Check the generated files before loading. Delimiters, escaped newlines, character sets, and NULL representations must match what the importer expects. A tab-delimited workflow is less convenient when the schema contains complex routines or cross-table ordering requirements, so preserve and apply those objects separately when necessary.

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

When a physical backup is the better answer

For very large or frequently restored systems, a physical backup copies database files in their original format instead of replaying every SQL statement. MySQL’s documentation says this is more appropriate for large-scale backup and restore because the files can be restored quickly. The trade-off is reduced portability: the backup must be compatible with the target server, storage engine, version, and file layout.

Use the physical-backup tool’s documented prepare, copy, and recovery sequence rather than copying a live data directory blindly. A physical restore can require stopping MySQL, ensuring ownership and permissions are correct, applying logs, and allowing crash recovery before clients reconnect. It is a planned migration or disaster-recovery procedure, not a drop-in replacement for an arbitrary .sql file.

Compatibility checks before production

Read the dump for settings that can change the result on the target server:

  • Character set and collation: verify that every referenced character set and collation exists on the target and that connection settings will not reinterpret bytes.
  • SQL mode: strictness, zero-date handling, and grouping rules can turn statements that succeeded on the source into errors or different results.
  • DEFINER clauses: views, routines, triggers, and events may refer to accounts that do not exist on the VPS. Create the required accounts or alter definitions through a controlled migration process.
  • GTID statements: replication metadata can conflict with the target’s GTID state. Decide whether the restore is for a standalone server or a replication topology before applying those statements.
  • Engine availability: confirm that tables using InnoDB, MyISAM, or another engine can be created and that their required plugins are enabled.

Test the exact command and credentials against a staging database when the data is sensitive or the production downtime window is narrow. A successful test also reveals whether the VPS has enough temporary and log space.

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

Validate the restore instead of trusting the prompt

Check process completion and errors

Confirm the client exit status, then search the log for error lines and warnings. A disconnected SSH window, an empty terminal, or a completed progress bar is not evidence that every statement succeeded. For a compressed pipeline, verify the decompressor status as well as the MySQL status, using pipefail where available.

Inspect databases and tables

Connect to the target server and list schemas:

mysql -e 'SHOW DATABASES;'

Select the restored database and inspect its tables:

mysql db1 -e 'SHOW TABLES;'

Check representative objects from small, medium, and large tables. Compare row counts with values recorded on the source:

mysql db1 -e 'SELECT COUNT(*) FROM important_table;'

Also verify that expected views, routines, triggers, events, and indexes exist. Row counts alone can miss missing objects or truncated values, so sample business-critical records and run application-level read checks before reopening traffic.

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

Plan for replication and application cutover

If the VPS will replace an active server, stop writes or establish a consistent export point before the dump is created. After loading, apply any changes made after that point according to your replication or migration plan, then update application credentials and connection endpoints. A logical import does not automatically synchronize new writes that occurred while the dump was being transferred.

Troubleshoot common failures

“No database selected” or “Unknown database”

Use the command for the dump’s actual format. Create the destination database and run mysql db1 < dump.sql when the file lacks a USE statement. For an all-databases dump, remove the database argument and let its embedded statements select each schema.

“Access denied”

Check the account, host restriction, authentication method, socket or port, and object privileges. The account running the client may differ from the account used by the application. Grant only the permissions required for the restore and test the connection separately before restarting a long import.

“No space left on device”

Stop and assess which filesystem filled: the dump location, MySQL data directory, temporary directory, or log volume. Delete only known-safe temporary files, expand storage, or move the dump. A compressed stream can avoid an extra uncompressed archive but cannot recover space already consumed by database files or logs. Do not assume that rerunning over a partially populated schema is safe; restore into a clean database or follow an explicit recovery plan.

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

Character-set, collation, or SQL-mode errors

Compare source and target server versions and inspect the failing statement in the log. Install or select a supported collation, set the intended session SQL mode, or regenerate the dump with compatible options. Do not silently replace a collation when it changes sorting or uniqueness rules without checking application behavior.

Packet-too-large or lost-connection errors

Large multi-row inserts can exceed packet limits or expose unstable network paths. Confirm client and server packet settings, run the client locally on the VPS, and consider regenerating the dump with smaller insert batches if the source workflow allows it. Resume only after determining whether the failed statement was committed; otherwise restart from a clean target.

The import stops when SSH closes

Run the process inside tmux or screen, detach deliberately, and reconnect later to inspect the process and log. A terminal multiplexer protects the session from ordinary SSH disconnects, but it does not protect against VPS reboots, OOM kills, disk failure, or a database crash.

The command appears idle

Large inserts, index builds, or storage stalls may produce no terminal output. Check the log timestamp, MySQL activity, CPU, disk I/O, free space, and process state from a second session. Do not kill the client solely because the screen is quiet. If the process has exited, use the log and exit status to identify the first failed statement before deciding whether a clean restart is required.

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 practical runbook

  1. Record source and target MySQL versions, storage engines, character sets, collations, SQL mode, and required accounts.
  2. Check free space for the archive, database files, temporary work, redo/undo activity, indexes, and logs.
  3. Transfer the dump to a protected directory on the VPS and verify its size or checksum.
  4. Inspect the header to determine whether it contains database-selection statements.
  5. Choose an uncompressed SQL, compressed stream, tab-delimited, or physical-backup workflow based on format and scale.
  6. Start tmux or screen, redirect output to a log, and enable pipeline failure reporting for compressed streams.
  7. Run the matching client command and wait for its exit status.
  8. Review errors, warnings, decompression failures, and disk or memory symptoms before declaring success.
  9. Inspect schemas, tables, indexes, routines, triggers, events, and representative row counts.
  10. Perform application read checks and complete the planned cutover or replication catch-up before allowing normal writes.

Bottom line

For a large .sql file on a VPS, copy it to the server and feed it to the command-line client: mysql < dump.sql when the file selects its own databases, or mysql db1 < dump.sql for a single-database dump without those statements. Use gunzip < db_name.gz | mysql db_name when transfer size or free disk space is the constraint. Keep the job inside tmux or screen, log everything, check exit statuses, and validate the restored data. If statement replay is too slow for the downtime window, a tab-delimited load or a compatible physical backup is the appropriate next step rather than trying to make a browser importer run longer.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver 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.