Skip to content

MySQL "ERROR 1064: You have an error in your SQL syntax" on a cPanel import or query

A query or a dump import dies with ERROR 1064. The fix is to read the part of the message after "near" — and to know the handful of cPanel-specific causes that produce it during restores.

ERROR 1064 (42000): You have an error in your SQL syntax is the parser refusing a statement it cannot understand. The full message always ends with check the manual that corresponds to your ... server version for the right syntax to use near '...' — and that fragment after near is the single most useful part of the error, because it points at the exact token where parsing broke. On a cPanel host, 1064 shows up in two situations: someone running SQL by hand in phpMyAdmin or the CLI, and — more often — a mysqldump restore that dies partway because the dump was made on a newer or different server than the one it is being loaded into. The fix is almost never “MySQL is broken”; it is a real syntax problem, and the near clause tells you where.

What’s happening

MySQL parses a statement left to right and stops at the first token that does not fit the grammar. The 1064 reports the text immediately after the breakage point, which is why the real error is usually just before what the message shows. A trailing comma, an unclosed quote or backtick, a reserved word used as an unquoted column name, or a stray character pasted from a word processor (a curly quote instead of a straight one) all produce 1064 at the spot where the parser gave up.

During a dump restore the cause is usually version drift. A dump taken from MySQL 8 or MariaDB 10.6 can contain syntax that an older target rejects: DEFAULT (expression) defaults, newer CHARSET/COLLATE names like utf8mb4_0900_ai_ci (MySQL 8 only — MariaDB does not have it), CREATE TABLE ... /*!80016 ... */ version-gated comments interpreted differently, or window-function syntax. The reverse also happens — a dump from a very old server using syntax a strict modern target rejects. The other restore-time classic is a truncated or concatenated dump file (an incomplete download, or two files cat’d together) where the parser hits a statement that was cut in half. Each of these is diagnosable from the line number the import reports and the near fragment.

How to verify

The error itself is the primary diagnostic — read what comes after near:

# Run the failing statement and look at the token after "near"
mysql cpuser_dbname -e "SELECT * FROM order WHERE id=1;"
# ERROR 1064 ... near 'order WHERE id=1' — 'order' is a reserved word

For an import failure, the error names the line number — go look at that line in the dump:

# The import reports: ERROR 1064 ... at line 4821
sed -n '4818,4824p' /home/cpuser/dump.sql

# Check what server the dump came from — it's in the header
head -20 /home/cpuser/dump.sql | grep -iE 'version|Server version|MySQL dump'

# What server are we restoring INTO?
mysql -e "SELECT VERSION();"

If the dump is large, confirm it is intact rather than truncated:

# A complete mysqldump ends with this line
tail -5 /home/cpuser/dump.sql | grep -i 'Dump completed'

# Size sanity — a truncated download is a common 1064 cause
ls -lh /home/cpuser/dump.sql

The fix

  1. Read the token after “near” first — it points at where parsing failed, so the real mistake is usually the word or symbol just before it. near 'FROM' often means a trailing comma in the column list above; near ')' often means an extra or missing parenthesis; near '' (empty) usually means an unterminated string or the statement ended unexpectedly. Fix that specific spot rather than rewriting the whole query.
  2. Quote reserved words used as identifiers — columns or tables named order, group, key, desc, rank, system are reserved words and must be wrapped in backticks: SELECT * FROM \order“. This is the most common hand-written 1064. If you control the schema, renaming the column avoids the problem permanently.
  3. Fix the dump’s version-specific syntax during restore — if the import dies at a CREATE TABLE using utf8mb4_0900_ai_ci (MySQL 8) being loaded into MariaDB, edit the dump to a collation the target supports (utf8mb4_general_ci or utf8mb4_unicode_ci). For other version-gated syntax, re-dump from the source with compatibility flags (mysqldump --compatible=...) or with --no-tablespaces and a matching --default-character-set. Matching the dump to the target server version up front prevents the whole class.
  4. Re-export with the right client version — a mysqldump run with a client newer than the target can emit syntax the target cannot parse. Run mysqldump from a client matching the destination server version, or add --set-gtid-purged=OFF and --column-statistics=0 (the latter is a frequent 1064/unknown-option culprit when dumping with the MySQL 8 client). Re-dumping is cleaner than hand-editing a large file.
  5. Repair a truncated or concatenated dump — if tail does not show Dump completed or the file size looks wrong, the dump is incomplete and the parser is hitting a half-written statement. Re-download or re-create the dump; do not try to patch the cut point by hand. Two dumps accidentally concatenated produce a 1064 where the second file’s header begins — split them.
  6. Strip smart quotes and hidden characters — SQL pasted from a word processor, email, or a PDF often carries curly quotes (’ “ ”) or non-breaking spaces that the parser rejects. Retype the statement in a plain editor, or run the file through a cleanup (tr or an editor’s “replace smart quotes”). A 1064 on a statement that “looks fine” is frequently an invisible character.
  7. Test the corrected statement in isolation — before re-running a whole import, paste just the failing statement (from the line number) into the CLI and confirm it parses. For an import, once the offending statement is fixed, restart the restore; if it dies again further down, the dump has a systemic version problem and re-exporting (step 3/4) beats fixing statements one at a time.

The fastest path through 1064 is to stop reading it as “MySQL error” and start reading it as a compiler pointing at a line: the near clause and the reported line number take you to the exact character, and on cPanel restores the usual culprit is a dump that does not match the server it is being loaded into. Stack Harbor handles cross-version dump restores and SQL-syntax failures under cPanel/WHM management — start a conversation when an import keeps stopping on 1064.