You can't feed a ZIP file directly to a database server. First unzip it to a working folder, identify what's inside, then restore that payload—a .sql dump, a native backup (.bak, .dump, .backup), or a physical data directory—using the tool that matches its format. The key condition is matching the restore method to the actual file type and to the exact server version that produced it. Do those two things and the restore is usually routine; skip them and you get cryptic errors, partial imports, or a database that looks fine but is missing data.
This guide walks through the full sequence: preparing your environment, extracting and inspecting the archive, picking the right restore path for MySQL/MariaDB, PostgreSQL, SQL Server, and SQLite, then verifying success and troubleshooting the failures people actually hit. Commands are written for a command-line environment because that's where restores are most reliable and repeatable, but the logic applies equally to GUI tools.
Understand what the ZIP might actually contain before touching a server
"Restore a database from a ZIP" describes a container, not a format. Database engines don't read ZIP archives, so the archive is only transport. What matters is the payload, and in practice it's one of four things:
A plain-text SQL dump — a .sql file full of CREATE TABLE and INSERT statements. Restore by running the script through the client (mysql, psql, sqlcmd) against a target database. A native logical backup — mysqldump --tab output, a PostgreSQL custom-format .dump, a directory-format dump, or a SQL Server .bak. These need the engine's own loader (mysqlimport, pg_restore, RESTORE DATABASE). A physical backup — a raw copy of a data directory, tablespace files, or an .mdf/.ldf pair. These require the server to be stopped (or the files placed with the server offline) and must match the server version and platform. Supporting artifacts — a schema.sql plus separate data files, a manifest, or a README the original admin left behind. Read it.
That distinction drives everything else. A 50 MB .sql file and a 50 MB .bak cannot be restored the same way, and no amount of ZIP tooling changes that. So the first real step is inspection, and the inspection happens after extraction, not before—though you can peek at the archive listing first.
Also confirm the source server version. A dump produced by MySQL 8.0 may use syntax a 5.7 server rejects; a SQL Server .bak from a newer major version cannot be restored on an older instance at all. If you don't know the version, look inside a text dump's header comments (-- MySQL dump 10.13 ..., -- PostgreSQL database dump) or check the backup documentation that came with the file.
Prerequisites for a ZIP-based restore
Gather these before you start, because a half-extracted archive and a missing client binary is the most common way people stall:
The archive itself, plus enough free disk space for both the compressed file and its uncompressed contents—sometimes two to three times the archive size for text dumps and native backups. The matching client or server tools: mysql/mariadb client for MySQL-family dumps, psql and pg_restore for PostgreSQL, sqlcmd or SSMS for SQL Server, the sqlite3 shell for SQLite files. Credentials and privileges to create or write to the target database: CREATE, INSERT, ALTER, and often DROP if the dump includes DROP TABLE IF EXISTS. A target: either an empty database you create first, or explicit permission to overwrite an existing one. Never restore over production without a tested backup. Enough server capacity: check max_allowed_packet (MySQL), statement timeout and disk space (PostgreSQL), and database file growth limits (SQL Server) before large loads.
A quick sanity check on versions saves time later. Run mysql --version, psql --version, or sqlcmd -? to confirm the client is installed and roughly current. Version skew between client and server is usually tolerated within a major release but is worth knowing.
Extract the archive and inspect what's inside
Work in a dedicated folder. On Linux or macOS, use unzip; on Windows, use PowerShell's Expand-Archive or File Explorer's built-in extractor. Extract to a path with no spaces if you're scripting.
1: List the archive contents without extracting to see the payload type: Linux/macOS: unzip -l backup.zip Windows PowerShell: Expand-Archive -Path backup.zip -DestinationPath .\restore -WhatIf (dry run) or list with tar -tf if it's a .tar.gz. 2: Extract to a clean folder: unzip backup.zip -d ./restore (or Expand-Archive -Path backup.zip -DestinationPath .\restore). 3: Identify the payload with ls -lh ./restore or dir .\restore. Look for .sql, .dump, .bak, .sqlite, or a directory tree. 4: Peek at text formats with head -n 50 file.sql to confirm the engine and version comments. For binary formats, rely on the extension and any accompanying README. 5: Check integrity if the archive came with a checksum: sha256sum backup.zip and compare against the published value. This catches truncated downloads before you waste time on a failed restore.
Success check: you now have an uncompressed payload whose format you can name and whose engine version you can state. If the archive contains nested archives, extract those too before proceeding—nested ZIPs are legal but they're a common source of "the file is empty" confusion.
Stop condition: if extraction reports CRC errors or the archive is password-protected and you don't have the password, don't keep retrying. Get a fresh copy from the source. Corrupted archives rarely restore cleanly.
Restore a MySQL or MariaDB dump from a ZIP
For a .sql dump, restore with the mysql client. Create the target database first, then pipe or redirect the file.
1: Create an empty target database (adjust the name and charset): mysql -u root -p -e "CREATE DATABASE appdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" 2: Run the dump against it: mysql -u root -p appdb < ./restore/appdb.sql Or stream without a shell redirect: mysql -u root -p appdb < <(unzip -p backup.zip appdb.sql) on Linux, which avoids writing the uncompressed file to disk. 3: Watch for errors. The client prints errors and continues by default. Add --force only if you deliberately want to skip failing statements—usually you don't. 4: For large dumps, consider --max_allowed_packet=256M on both client and server, and check innodb_buffer_pool_size. A text dump can run for hours; it's normal.
For a native mysqldump --tab directory (schema .sql files plus .txt data files), create tables from the schema files, then load the text data with mysqlimport or LOAD DATA INFILE. For a mysqlpump or mydumper archive, use the corresponding loader (myloader for mydumper output).
Success check: SHOW TABLES; lists the expected tables, and SELECT COUNT(*) on a few large tables returns non-zero counts consistent with the source. A quick row-count spot check beats a full comparison when you just need confidence.
Restore a PostgreSQL dump from a ZIP
PostgreSQL dumps come in three flavors, and the restore command differs for each:
Plain-text .sql: psql -U postgres -d appdb -f ./restore/appdb.sql Custom format (.dump): pg_restore -U postgres -d appdb ./restore/appdb.dump Directory format: pg_restore -U postgres -d appdb ./restore/appdb_dir/
Create the target database first with createdb or psql -c "CREATE DATABASE appdb;". For custom and directory formats, pg_restore can create the objects itself if you pass --create, but it's clearer to create an empty database and restore into it. Use -j 4 to parallelize across four workers on multi-core machines, and --no-owner when the original role names don't exist on the target.
For a .sql file, a common gotcha is encoding. If the dump was made with --encoding=UTF8 and your client is set differently, you'll see mojibake in text columns. Set PGCLIENTENCODING to match before restoring. For very large restores, psql -1 wraps everything in a single transaction so a failure rolls back cleanly—but that can be slow on huge datasets, so use it deliberately.
Success check: \dt in psql lists the expected tables, and SELECT COUNT(*) on key tables matches the source. pg_restore exits non-zero on any error, so a clean exit code is your first signal.
Restore a SQL Server backup from a ZIP
SQL Server .bak files must be restored through RESTORE DATABASE; you cannot run them as scripts. The ZIP wrapper usually just contains a .bak and sometimes a .trn transaction log.
1: Extract the .bak to a folder the SQL Server service account can read—not a personal user folder, which often lacks the right permissions. 2: Inspect the file list inside the backup so you know the logical names and file locations: RESTORE FILELISTONLY FROM DISK = 'D:\restore\appdb.bak'; 3: Restore with explicit move clauses to avoid writing over existing files: RESTORE DATABASE appdb FROM DISK = 'D:\restore\appdb.bak' WITH MOVE 'appdb' TO 'D:\data\appdb.mdf', MOVE 'appdb_log' TO 'D:\data\appdb_log.ldf', RECOVERY; 4: Check version compatibility first. A backup from a newer major version (for example, SQL Server 2022) cannot be restored on an older instance (for example, 2019). If you hit this, the fix is to restore on a matching or newer instance, then script out and re-import—there's no supported downgrade path for a .bak.
If the archive contains .mdf/.ldf files rather than a .bak, that's an offline-database copy. Attach it with CREATE DATABASE ... ON (FILENAME = ...) FOR ATTACH; after copying the files into a location the server controls. Attaching untrusted .mdf files is riskier than restoring a proper backup, so prefer a .bak when you have the choice.
Success check: SELECT name FROM sys.databases; shows the database, and DBCC CHECKDB('appdb'); returns no consistency errors. On production servers, run CHECKDB during a maintenance window, not during peak load.
Restore SQLite files from a ZIP
SQLite is the simplest case: the database is a single file, so "restore" usually means "copy the .sqlite or .db file into place."
1: Extract the file from the archive. 2: Stop anything using the target database file—SQLite allows concurrent readers but you don't want a half-written restore. 3: Copy the extracted file over the target path, keeping a backup of the current one. 4: If the archive instead contains a .sql script, run sqlite3 appdb.db < restore.sql to build the database from scratch.
Success check: sqlite3 appdb.db "PRAGMA integrity_check;" should output ok. A separate PRAGMA foreign_key_check; catches referential problems the integrity check doesn't.
Verify the restore actually worked
A restore that exits cleanly can still be incomplete—particularly when the client continues after errors, as mysql does by default. Verification should confirm three things: schema completeness, data presence, and application-level sanity.
Object counts: compare table, view, and index counts between source and target. information_schema.tables gives a quick inventory on MySQL and PostgreSQL; sys.objects does it on SQL Server. Row counts on key tables: spot-check the five or ten largest or most business-critical tables. Exact matching across every table is expensive; targeted checks catch most truncation. Constraint and index health: run the engine's consistency tool—DBCC CHECKDB on SQL Server, ANALYZE plus amcheck on PostgreSQL, CHECK TABLE on MySQL—to confirm the restored data is intact. Application smoke test: point a staging instance at the restored database and exercise login, a read, and a write. That's the only check that proves the restore is usable, not just present.
Document the row counts and object counts you verified. If a later problem appears, that baseline tells you whether the restore was ever complete.
Troubleshoot the failures you're most likely to hit
Symptoms cluster around a handful of causes, and the reversible checks come first.
"Access denied" or "authentication failed." The credentials lack CREATE/INSERT on the target, or the target database doesn't exist. Create the empty database first, then retry. On MySQL, check GRANT statements; on PostgreSQL, check pg_hba.conf and role membership.
"Unknown database" or "database does not exist." You restored into a nonexistent target. mysql and psql need the database to exist before running a script.
"You have an error in your SQL syntax" near the start. Version skew—a newer dump on an older server, or a dump that includes settings the target doesn't support. Restore into a server of the matching major version, or edit out incompatible statements if it's a one-off migration.
"The media set has N media families but M are provided" (SQL Server). The backup is split across multiple files that weren't all extracted. Extract every file from the archive before attempting the restore.
"Permission denied" writing to the data directory. The restore is running as a user the server doesn't control, or the .bak is in a folder the service account can't read. Move the file and retry.
"max_allowed_packet" errors (MySQL). A long INSERT exceeds the packet limit. Raise max_allowed_packet on both client and server to 256M or more, or use a dump produced with --extended-insert and smaller batches.
Empty database after a "successful" restore. The client skipped all statements because it couldn't connect to the target, or it restored into a different database than you expected. Re-run with verbose output and check the target name.
Stop condition: if the archive is corrupt, the backup is from a version you can't match, or the restore repeatedly fails mid-load with storage or memory errors, stop troubleshooting and escalate. Contact the person who produced the backup, the database administrator for that environment, or the hosting provider. Repeated partial restores against production are how you turn a recoverable situation into data loss.
Why this is worth doing carefully
The ZIP wrapper is the least interesting part of the job. What matters—matching format to loader, matching server versions, verifying completeness—is the same discipline as any restore, just with an extra extraction step. The failures that bite are rarely exotic; they're version mismatches, missing target databases, and skipped verification. A ten-minute check of the archive contents and a five-minute row-count spot check prevent most of them.
If the source database carried personally identifiable information, treat the extracted files as sensitive: delete them from the working folder after the restore, and don't leave uncompressed dumps in shared directories. The restore is finished only when the data is safely in the database and the temporary copies are gone.