-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Error 3988: Conversion from collation utf8mb4_general_ci into latin1_swedish_ci impossible for parameter #1298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Failed to reproduce.
|
@methane You will get that error with strict mode enabled, but when it is disabled it will just produce a warning instead and you can reproduce the behaviour I mentioned.
My issue is that even with strict mode disabled, I am getting an error - specifically, error 3988 - when I do an insert or update query with the Go sql driver. https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sql-mode-strict |
I just used the default MySQL. That's why "complete steps to reproduce" is important. You should provide whole step, and confirm the steps can reproduce your problem before reporting issue. Now you said "even with strict mode disabled", but you didn't say the step to disable the "strict mode". I can not confirm the issue. I don't want to waste my time by trying to reproduce your issue without enough information. |
I will reopen this issue if you can provide the complete steps to reproduce with Docker MySQL. |
Currently, i am also facing this type of issue, but in my case its giving "Error 3988: Conversion from collation utf8_general_ci into utf8mb4_0900_ai_ci impossible for parameter". I am working on Golang and db is MySQL. Can anybody help? |
Hi, do you fix it now?i am also facing this type of issue |
Hi @kouhuang, I kept the encoding as it is ut8mb4 only and in my case i had to store emojis along with the text in the database so i used base64 encoding and decoding and it worked. I was able to store the emojis in that way. |
Do you have any clues on the root cause? I am getting the same error and it is super weird. I can't really understand the actual condition when it is failing. I have a Java code that connects to a MySQL server and uses batch execution of multiple INSERT statements. And that is what is failing:
I thought it is something with the data I am inserting but my tests didn't prove that: the error was happening when I was inserting 10 rows. So I changed my program to insert only the first row, then the first two rows, and so on. It failed when I tried to insert the first 4 rows. So I thought that is something with the data in the fourth row. But then I tried to insert just that fourth row by itself and it went through just fine. I.e. it is not about the data in the fourth row but something else. And I can't understand what is that "else". |
The INSERT statement I am using:
I thought it might be because of that |
This is not Q&A forum. Do not ask about error happened in your environment. |
I am not asking about the error that happened in my environment. I am asking about the error reported in this issue. And with the hope that it may help with identifying the root cause I provided details of how it happened in my case. So far it doesn't seem like the problem was solved. My issue happened with MySQL which is, as far as I understand, this project is about. The error comes from the database but not from the Go itself. So I can't see a reason why my environment should matter in that case. |
Root cause is obvious: wrong configuration. |
there can also be charset mismatch between client config and mysql, make sure client is using same charset while connecting to DB |
It is what I meant. User need to specify correct collation. Original issue that @justin-wilxite reported is: database used latin1 but client used utf8. Issue reported by @kvirund is same. Issue reported by @shubham-zs is bit different. Connection encoding was utf8mb3_general_ci too. In all cases, chose the right connection collation fix the issue. FWIW, next go-mysql (v1.8.0) will make configuration bit easier, especially for @shubham-zs case. User don't need to know much about the default collation of server. They need to know only the default charset of the database. They can specify only charset like See https://github.com/go-sql-driver/mysql#charset and #745 (comment) for detail. Additionally, see links I wrote in #1298 (comment). It is very important. |
Oh, I was wrong. You can specify only charset even with current v1.7. It was not recommended in the README, but it was not bad and I recommend it for many users who don't care about collation. They should use server's default collation of the charset and specify only What changed in v1.8 is setting both of charset and collation. go-mysql v1.8 will send |
Issue description
I'm encountering this error when attempting to insert or update a latin1 column with a text parameter that is utf8 encoded and which contains unsupported characters.
Error 3988: Conversion from collation utf8mb4_general_ci into latin1_swedish_ci impossible for parameter
If I run the same query from the mysql command line, or using the PHP PDO client, there is no error and the unsupported characters are replaced with ?s. I'd prefer to get that behaviour instead of the error.
This is specific to MySQL 8.
Example code
Configuration
Driver version (or git SHA): 1.6.0
Go version: 1.17.5
Server version: MySQL 8.0.23
Server OS: CentOS
The text was updated successfully, but these errors were encountered: