Thursday, February 24, 2011

Got error message when trying to import restore mysqldump database file to database

Got error message when trying to import restore mysqldump database file to database

ERROR 1064 (42000) at line 467: 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

As of MySQL 5.0.54, mysql ignores Unicode byte order mark (BOM) characters at the beginning of input files. Previously, it read them and sent them to the server, resulting in a syntax error. Presence of a BOM does not cause mysql to change its default character set. To do that, invoke mysql with an option such as --default-character-set=utf8.

# pkg_info | grep -i mysql
mysql-client-5.5.9 Multithreaded SQL database (client)
mysql-server-5.5.9 Multithreaded SQL database (server)

# mysql --default-character-set=utf8 -u user_name -p db_name < db_dumped.sql

To check if a file contains UTF-8 BOM at header

1 comment:

owlgirl said...

YOU JUST SAVED MY NIGHT. i am so thankful. -- i love those two small dashes and this entry. THANK YE SO MUCH.