MySQL Database

ID #265

Why do I get a query syntax error 1064 from MySQL when the syntax seems correct?

Applies to: Grid System

You will get a MySQL query syntax error number 1064 when you incorrectly use a reserved word in your query such as "when" or "order".

Each version of MYSQL reserves different words. Comphrensive lists for recent versions can be found here.

Last update: 2011-02-18 09:44
Author: FAQ Admin
Revision: 1.3

Digg it! Share on Facebook Print this record Send FAQ to a friend Show this as PDF file
Please rate this FAQ:

Average rating: 2.85 (84 Votes)

completely useless 1 2 3 4 5 most valuable

You can comment this FAQ

Comment of Anonymous:
The error 1064 occurs due to Mysql version mismatch,because differnt versions have differnt
reserved words,which if used by a previous version causes the error to occur.

The simplest and most effective solution for it is.
-when using phpMyadmin,select the "compatibility mode" & select the target db version from the drop down box.
-when using MySql administrator,while backing up choose "compatibility mode" in adavanced tab ,
and while restoring through mysql administrator ,click "auto-detect file charater set" if backup was not made using mySql administrator.
the default file characer set used by mysql admministrator is utf8.

Taking these precautions, generally should get the things working for you.
however there maybe some exceptions to this solution.
In that case you will have to see the error it is giving .
say for eg, in my case error was
Error Code : 1064 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 'DEFAULT CHARSET=latin1
Here i could replace latin1 with utf8,
because my target version of mysql was different from the from which i took backup.
In case of other serious errors you may
search mysql forums

Nitin Kaul

Added at: 2006-06-29 06:18

Comment of RdInfXNk:
Hats off to woehver wrote this up and posted it.
Added at: 2012-01-07 00:46