Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR 1064 (42000) in MySQL

I am trying to populate a new MySQL empty database with a db dump created from MS SQL Azure database, and I get the following error

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

I used mysqldump to perform this operation and used command similar to the following in the command prompt:

mysql --user=rootusername --pasword=password databasename < dumpfilename.sql

Mysqldump took about 30 minutes to display this error message.

like image 803
siva636 Avatar asked Aug 09 '11 15:08

siva636


2 Answers

(For those coming to this question from a search engine), check that your stored procedures declare a custom delimiter, as this is the error that you might see when the engine can't figure out how to terminate a statement:

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

If you have a database dump and see:

DROP PROCEDURE IF EXISTS prc_test;
CREATE PROCEDURE prc_test( test varchar(50))
BEGIN
    SET @sqlstr = CONCAT_WS(' ', 'CREATE DATABASE',  test, 'CHARACTER SET utf8 COLLATE utf8_general_ci');
    SELECT @sqlstr;
    PREPARE stmt FROM @sqlstr;
    EXECUTE stmt;
END;

Try wrapping with a custom DELIMITER:

DROP PROCEDURE IF EXISTS prc_test;
DELIMITER $$
CREATE PROCEDURE prc_test( test varchar(50))
BEGIN
    SET @sqlstr = CONCAT_WS(' ', 'CREATE DATABASE',  test, 'CHARACTER SET utf8 COLLATE utf8_general_ci');
    SELECT @sqlstr;
    PREPARE stmt FROM @sqlstr;
    EXECUTE stmt;
END;
$$
DELIMITER ;
like image 123
msanford Avatar answered Sep 18 '22 13:09

msanford


Error 1064 often occurs when missing DELIMITER around statement like : create function, create trigger.. Make sure to add DELIMITER $$ before each statement and end it with $$ DELIMITER like this:

DELIMITER $$
CREATE TRIGGER `agents_before_ins_tr` BEFORE INSERT ON `agents`
  FOR EACH ROW
BEGIN

END $$
DELIMITER ; 
like image 29
Adel Ben Hamadi Avatar answered Sep 20 '22 13:09

Adel Ben Hamadi