4

I am getting this error when doing a big insert query into a table on MySQL 8:

Error 3988: Conversion from collation utf8mb4_general_ci into latin1_swedish_ci impossible for parameter

The data originally comes from a table with the utf8mb4 character set and then after processing it is inserted into a table with the latin1 character set.

It's getting stuck on this two-byte character: ż.

Is there an easy way for me to get MySQL to replace or strip out these characters, or a way for me to sanitise the input without sacrificing characters like ä which it seems to be able to handle?

Baryon
  • 53
  • 1
  • 6
  • Could you manually do some diacritic conversions prior to moving the data? See [this](https://stackoverflow.com/questions/4813620/how-to-remove-accents-in-mysql#answer-6945191) as an example. If you didn't want to alter the source data, you could also look to do this in a stored procedure. – War10ck Jan 06 '22 at 19:52
  • Convert charset firstly (use CONVERT() function) then apply needed collation. – Akina Jan 06 '22 at 19:54
  • The strange thing is, when I try to insert unsupported characters into the latin1 table on the mysql command line, it succeeds and just converts the characters to ?s. I can't reproduce the error other than in my go program, which makes me think there could be a session variable that's relevant. collation_connection is set to utf8mb4_general_ci on both though – Baryon Jan 07 '22 at 14:39

1 Answers1

1

If you use PHP framework like Laravel try to find file called database.php in config directory anf change mysql configs to latin1_swedish_ci enter image description here

Levon Babayan
  • 266
  • 2
  • 18