ERROR 1064 (42000) in MySQL
(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 ;
Do you have a specific database selected like so:
USE database_name
Except for that I can't think of any reason for this error.
For me I had a
create table mytable ( dadada )
and forgot the semicolon at the end.
So looks like this error can occur after simple syntax errors. Just like it says.. I guess you can never read the helpful compiler comments closely enough.