mysqldude
Error codes › 1064

MySQL & MariaDB error 1064: You have an error in your SQL syntax

MySQLYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '…' at line …
MariaDBYou have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '…' at line …
Example from our test runs: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('Reset0pw!') WHERE user= (8.0.46) · You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'c WHERE c.sessionid = 1 (10.6.28)

The parser could not understand the statement. The text after "near" is where it gave up, and the real mistake is usually just before it.

MySQLMariaDB
SymbolER_PARSE_ERRORER_PARSE_ERROR
SQLSTATE4200042000
TypeServer errorServer error
Versionsevery release since 5.0 activeevery release since 5.5 active

What it means

1064 is the parser’s general “I can’t read this” error. It doesn’t say what is wrong, only where parsing stopped: …for the right syntax to use near 'salary FROM emp WHERE' at line 1. The mistake is almost always immediately before the quoted text. If the quoted text is empty (near '' at line 1), the statement ended too early.

Why it happens

  • A missing or extra comma, bracket or quote.
  • A reserved word used as a table or column name. Words become reserved over time: RANK, ROWS, GROUPS, FUNCTION, SYSTEM and 22 others became reserved in MySQL 8.0, so SELECT salary AS rank works on 5.7 and fails with 1064 on 8.0. See the reserved words by version.
  • Syntax from another database or another version: TOP 10 (SQL Server), ALTER IGNORE TABLE (removed in MySQL 5.7), GRANT … IDENTIFIED BY (removed in MySQL 8.0), window functions on MySQL 5.7.
  • Statements meant for the mysql command-line client (DELIMITER $$, source file.sql) sent through an application driver, which sends them to the server literally.
  • Smart quotes (‘ ’ “ ”) pasted from a document instead of plain ' and ".

How to fix it

  • Look at the text right before the near '…' part, and check commas, brackets and quotes there.
  • Put backticks around any identifier that could be a keyword: SELECT salary AS `rank` FROM emp. Use the reserved words table when upgrading.
  • Check the statement is valid for your version: SELECT VERSION();
  • Drop DELIMITER lines when running a procedure definition through a driver; send the CREATE PROCEDURE as one statement.

Reproduce it yourself

These steps are the exact test our harness runs. Use a scratch server, never production.

  1. Connect with mysql -u root -p and create a scratch database and the test data:

    CREATE DATABASE demo;
    USE demo;
    CREATE TABLE emp (id INT, name VARCHAR(20), salary INT);
    INSERT INTO emp VALUES (1,'Ann',100),(2,'Bob',200);
  2. Run:

    SELECT id name, salary FROM emp WHERE;

You get: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1(11.8.9)

Verified fixes

  1. Quote reserved words with backticks

    SELECT name, salary AS `rank` FROM emp ORDER BY id;

Tested on

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
A missing comma between columns
repro
✓ 1064✓ 1064✓ 1064✓ 1064✓ 1064✓ 1064✓ 1064✓ 1064✓ 1064
A column alias that became a reserved word (RANK in MySQL 8.0)
version check
≠≠✓ 1064✓ 1064✓ 1064≠≠≠≠
Quote reserved words with backticks
fix
✓✓✓✓✓✓✓✓✓
A missing comma between columns repro
MySQL 5.6✓ 10645.7✓ 10648.0✓ 10648.4✓ 10649✓ 1064
MariaDB 10.6✓ 106410.11✓ 106411.4✓ 106411.8✓ 1064
A column alias that became a reserved word (RANK in MySQL 8.0) version check
MySQL 5.6≠5.7≠8.0✓ 10648.4✓ 10649✓ 1064
MariaDB 10.6≠10.11≠11.4≠11.8≠
Quote reserved words with backticks fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9
What the warnings and failures say (1)
  • A column alias that became a reserved word (RANK in MySQL 8.0) (MySQL 5.6, MySQL 5.7, MariaDB 10.6, MariaDB 10.11, MariaDB 11.4, MariaDB 11.8): expected error 1064 did not occur

Related errors

  • 1054 ER_BAD_FIELD_ERRORexplained
  • 1146 ER_NO_SUCH_TABLEexplained
  • 1149 ER_SYNTAX_ERROR

Where this error shows up in our guides

How the message changed between versions
MariaDB fromSymbolMessage
5.5.68ER_PARSE_ERROR%s near '%-.80s' at line %d
10.2.44ER_PARSE_ERROR%s near '%-.80T' at line %d
11.8.10ER_PARSE_ERROR%s near '%-.80sT' at line %d