I am trying to set up a development and testing environment for the software of my new employer.

The data is quite complex and due to some shortcuts/bad architecture decisions of the company that built the software, fake data won't do. So our plan is to download an SQL dump of the production db, anonymize some sensitive information with a faker script and then load it into a locally running docker container.

But when I try that, I get different errors such as:

'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...'

So basically the dump which is from our hosting provider IONOS, is not compatible with my docker MySQL db. But both dbs, my dockered db and the one running on IONOS shared hosting, are version 8.0.36.

I have done the SQL dump via the web UI. We do not dare to download it via terminal.

Does anyone know of that problem and might suggest a fix?

8 Replies 8

I would investigate the errors and determine what went wrong and how to fix the errors. There is no magic bullet here. It is possible that the issue is with the export function of whatever mysql UI you used. If you want more concrete help, then you should ask a proper question with the sql code that produces the error, the exact error message, table definition (if relevant) and naming the exact version of the mysql UI you used.

thanks for your reply.

There are different problems, like there are definer clauses or there are HTML tags in the SQL dump, etc. So there are different syntax errors that all lead to "You have an error in your SQl syntax..."

I have fixed a couple of them with a python script that goes through the SQL and searches for regex and replaces/deletes stuff. But this obviously is not a good solution and has never fixed all the issues.

But maybe there is some library that does that with a script or so? I mean I cant be the first person to encounter this issue.

Asking us to recomment any off site resource is explicitly off topic here on SO as such questions attract a lot of spam.

If the malformed sql dump was generated by the mysql UI, then you need to use a different data dumping solution.

If the malformed dump is the result of subsequent processing by you, then I would look at your script.

What web UI? MySQL doesn't have a web UI of its own.

Are you using phpmyadmin? What version? Some versions of phpmyadmin have had bugs related to the dump/export feature — it may generate output that causes errors when trying to import to a MySQL instance.

It would help if you show the full syntax error message. You truncated the error message at near... which obscures the nature of the error.

You'd investigate what does your "dump" is. Common dump is text file which contains correct SQL queries, so you'd see that it is a text, SQL queries are correct, lines delimiter and encoding is the same for both servers, and so on...

I remember running into an issue somewhat similar. Turned out the characterset and collation was setup differently and there were data in the source DB that the destination DB wouldn't accept. You should post the error message. SQL dump is a part of MySQL, it is the same in everywhere at least for the same version of MySQL.

So the complete error meassage reads:

line 2870967: 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 1ax to use near ')' at line 1

I checked out the line and more parantheses are being closed than opened. But as I have said, this was created via web UI dump, which is directly from IONOS, it is not PHP My Admin. I dont know the exact command it uses. But there should not be any errors in it.

The thing you said, Allen, makes totally sense. I guess before that line, there is some data that cannot be parsed and that way an opened paranthesis cannot be read.

Is there a fix for this?

I have contacted IONOS, and they suggested some fixes. I'll try them out on Monday. If anything works I'll post it here for future reference.

You would get an invalid string value error if mysql detected a character it cannot parse. Syntax errors indicate issues with how the dumping tool exports data. My guess would be that the dumping tool incorrectly tries to escape text data that contains parentheses or you did not configure the tool to use escape character.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.