0

I get this error:-

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 ' at line 1

whenever I tried something like this:-

mysql> source /home/user1/sql/ddl.sql
mysql> source /home/user1/sql/insert.sql
mysql> source /home/user1/sql/cleanup.sql

The intresting thing is, this happen to each and every one of the sql scripts but only the first statement is corrupted. The rest of the statements in the script will run fine. I have worked around this by putting a dummy statement in every script.

Anyone had this problem before? I am completely stumped and checking Google hadn't helped yet. Thanks in advance.

2 Answers 2

6

A possibility is that the SQL files were written in Unicode with a BOM, which MySQL cannot interpret.

That would explain the symptoms.

A solution is to open them in a decent editor and save them back without it.

Example in VIM:

Force BOM removal

:set nobomb

Save and quit

:x!
Sign up to request clarification or add additional context in comments.

1 Comment

How do I correctly save the file without the BOM? I have tried using Visual Studio 2008, Notepad, SciTE, and vim to resave those files and they still give the same error.
2

Your input files may contain a Unicode BOM, which is a bit of cruft that some programs such as Notepad place at the start of the file to indicate the file format.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.