Errors··5 min read

MySQL Error 1064 on Import: 'You Have an Error in Your SQL Syntax'

Error 1064 during an import almost never means your dump is broken. It usually means a version mismatch or a truncated file. Here's how to pin it down.

Error 1064 — 'You have an error in your SQL syntax' — is MySQL's catch-all parser complaint. On a fresh import it rarely means the dump is genuinely malformed. It almost always points to one of three things.

Cause 1: The file was split with a dumb tool

This is the most common one. If you split the dump with `split -l` or a text editor, you cut a statement in half. The first chunk ends mid-INSERT, the next begins mid-INSERT — and both throw 1064. The error message will quote a fragment that obviously isn't a whole statement.

Split at statement boundaries instead

A SQL-aware split never cuts an INSERT in half, so every chunk parses cleanly.

Open SQLSplit

Cause 2: Version mismatch (MySQL 8 → older MySQL/MariaDB)

A dump from MySQL 8 can contain syntax that MariaDB or MySQL 5.7 doesn't understand — new index options, functional defaults, or the /*!80000 ... */ version-gated comments. The error usually quotes the unfamiliar keyword. Fixes:

  • Re-export with --compatible or target the lower version explicitly
  • Strip MySQL-8-only clauses (e.g. VISIBLE/INVISIBLE indexes) from the schema
  • Import into the same major version you exported from when possible

Cause 3: Truncated or partially downloaded file

If the download or transfer was interrupted, the file ends mid-statement. Check that the dump ends cleanly:

tail -n 5 dump.sql
# A complete mysqldump ends with lines like:
# /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
# -- Dump completed on 2026-05-18

No 'Dump completed' line and no trailing semicolon? The file is incomplete — re-download or re-export it.

Pinpoint the exact line

The error reports a line number. Jump straight to it:

sed -n '12340,12360p' dump.sql

Nine times out of ten you'll immediately see a half-statement, a stray character, or a keyword your MySQL version doesn't know.

Frequently Asked Questions

Why do I get error 1064 when importing a SQL dump that worked before?

Usually because the file was split with a non-SQL-aware tool that cut a statement in half, or you're importing a newer MySQL dump into an older MySQL/MariaDB version. Split at statement boundaries and match the export/import versions.

Does error 1064 mean my SQL file is corrupted?

Not necessarily. More often it means a truncated download, a bad split, or version-specific syntax the target server doesn't understand. Check the last lines of the file for a clean 'Dump completed' marker.

How do I find which line causes error 1064?

The error message includes a line number. Use sed -n 'START,ENDp' dump.sql to view that section. You'll typically see an incomplete statement or unsupported keyword right there.

Related articles

View all

Advertisement