Linux, Web Server & Database
Import SQL Database
Import a .sql database file correctly into MySQL/MariaDB, including large files that fail through standard tools.
The Problem
You have a .sql file to import — from a backup, an export from another system, or a developer handover — but it's failing, timing out, or the standard web-based import tool can't handle its size.
About this problem
SQL file imports commonly fail for a handful of predictable reasons: the file is too large for a web-based tool's upload limit, a character set mismatch causes garbled data or an outright error, or the file references a database/table structure that conflicts with what's already there — each has a specific fix once identified correctly.
This comes up during migrations, setting up a local or staging copy from a production export, or receiving a database handover from another developer or agency.
What's Included
- Importing the SQL file via the command line, which avoids most web-tool size and timeout limits
- Verifying the file's character set matches the target database to avoid data corruption
- Checking for and resolving any structural conflicts with existing data
- Confirming the import completed fully and the data is usable
What's NOT Included
- Creating the SQL file itself if you don't already have one (see backup/export services)
- Fixing data quality issues that already existed in the original export
- Merging the imported data with existing data in a special way (this is a standard import, not a merge)
How It Works
- Check the SQL file's size and structure, and confirm which database it's intended for.
- Import via the MySQL command line directly, which handles far larger files than typical web-based tools without timing out.
- Verify the file's character set matches the target database's to prevent corrupting special characters.
- Watch the import process for any errors rather than assuming a completed command means full success.
- Spot-check table structure and row counts against expectations, then test the application against the imported data.
In practice: you buy the service, send over whatever access or details the job needs, I investigate and do the work, and you confirm it's resolved before we call it done.
Frequently Asked Questions
- Why does my SQL file fail to import through phpMyAdmin?
- Most web-based tools have an upload size and execution time limit, and a sufficiently large .sql file exceeds one or both — importing via the command line avoids this entirely.
- Can I import a SQL file into a database with a different name?
- Yes, as long as the file doesn't explicitly specify a database name internally, or that reference is adjusted before import — otherwise it can try to create or target the wrong database.
- What does 'Unknown character set' mean during import?
- It means the SQL file specifies a character set the target MySQL/MariaDB version doesn't recognise, often because the file came from a much older or newer database version.
- How long should a database import take?
- It depends heavily on file size — a few megabytes imports in seconds, while gigabyte-scale files can take considerably longer, which is worth planning for if there's a downtime window involved.
- Can I import a SQL file into a database that already has tables?
- Yes, but if table names overlap, it can error out or overwrite existing data depending on the file's structure — worth checking for conflicts before importing into a non-empty database.
- What's the safest way to import a large database file?
- Command-line import, after confirming character set compatibility and ideally against an empty target database or one you've already backed up, so a failed import is easy to roll back from.