wai
wai

Reputation: 9123

Strange MySQL syntax error

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.

Upvotes: 0

Views: 576

Answers (2)

Vinko Vrsalovic
Vinko Vrsalovic

Reputation: 340191

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!

Upvotes: 6

Greg Hewgill
Greg Hewgill

Reputation: 992857

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.

Upvotes: 2

Related Questions