How to Fix the MySQL 1064 Error

Fixing the "#1064 - You have an error in your SQL syntax" error in phpMyAdmin

Updated over a week ago

The "#1064 - You have an error in your SQL syntax" error indicates a syntax error in the SQL query statement. Since this may be due to a few different reasons, here are the most common ones and how to fix them:

  • Missing data - your database may have missing data. Double-check that your database has all the data it needs to complete the query

  • Command mistyping - If you entered the import command or any other manually, verify that it is spelled correctly in a SQL statement

  • Obsolete commands - some commands might be deprecated, meaning that they are no longer valid in the SQL statement

  • Database version mismatch - different MySQL versions have different reserved words. If you are using a previous version from when a word was not reserved, it can cause this error. To fix it, access your database via phpMyadmin and select the Import tab on the top selection bar:


    Next, locate the Format-specific options field and select the target database version from the SQL compatibility mode drop-down box:

What to Do if the Issue Persists

If you are importing a database and the error still appears after using compatibility mode, or you are getting an ERROR: ASCII '\0' message, you can try the following:

Create a backup copy of your database file before making any changes

  1. Open the database file (.sql) using a notepad application on your device

  2. Delete the first and last lines on the file

  3. Save the changes and try re-importing again

Additional Resources

Did this answer your question?