I'm trying to run a SQL file created by mysqldump and suprisingly I get a SQL syntax error while running the backup file on the DB. How can it be possible considering that the file was created with mysqldump? BTW the SQL error is not very indicative.
1 Answer
I've seen things like those happening due to reserve words (keywords)... To allow them you need to use option --allow-keywords
in your mysqldump command.
Try: mysqldump --allow-keywords ...
with your complete command options.
If this doesn't fix, share the error.
Update:
You might like to consider differences in character-set and as mentioned in this question.
Update-2:
As you suggested that the error is not because of the reserve words, I'd ask you to check if that's the encoding issues as mentioned here.
To use the same backup file, considering the issue is with encoding, you can change it using following steps:
- Find the encoding of a file:
file -bi FILENAME
- If the file is not in utf8 and you want to convert it you do it as follows:
iconv -f <source-encoding> -t utf8 FILENAME
You may try using the dump now.
When you say "ERROR 1064: (42000)" or "error in your SQL syntax" it's synonymous, it still doesn't convey what's causing the error. Glad to know the security precautions you're following not to post anything other than mysql error name and numbers. Anyhow, please try above and share.
-
Thank you for your answer. Why did it only start to happen now and more importantly, there is any way to fix the bug backup? I need something out of it Jul 28, 2015 at 7:28
-
This is a guess based on your description. Can you provide the exact error and at what syntax it's appearing? Jul 28, 2015 at 7:36
-
-
Did you try the suggestion? Is the table name a reserved word? There is an update on answer too... if that's the case. Jul 28, 2015 at 7:57
-
Well i also thought it might be about encoding but why suddenly? Backups worked just fine untill now Jul 28, 2015 at 7:59
sed
orperl
or other tools, but we need more info. Also the output ofmysqldump -V
and the querySELECT @@VERSION;
.