How to convert hungarian mysql entries to utf8
Asked Answered
T

1

0

I have understood in principle how to convert an existing database from latin to utf8. I have already been able to do this successfully with the database I have.

The existing data is in Hungarian. The database fields were previously set to latin1_german1_ci. As a result, words were stored in the database in this way:

Mária

but in the frontend correctly shown as:

Mária

If I now convert everything to utf-8, it works as it should for all new data. But the existing data was not converted in the database and is displayed in the frontend exactly as it is in the database:

Mária

Which makes sense to me because it is utf8. But it is not what I want of course. But how do I get all the existing data in the database to be converted to e.g. "Mária" in first place?

Thibodeau answered 20/4, 2022 at 17:5 Comment(2)
I just found out that SELECT CONVERT("Mária" USING latin1); was kind of what I was looking for. But I would want that for my whole database. I also would have never thought that I need to convert it to latin to get this result. Because I thought that´s what the collation was before. Sorry... not an MYSQL/utf8/latin-Expert here.Thibodeau
Never mind this is a monolog =) Should have done more research in first place. It seems this is what I need: #9408334 I was hoping there is something easier than manually looping through the tables. But it seems not.Thibodeau
T
0

That's a "Mojibake" problem (á in place of á) See Trouble with UTF-8 characters; what I see is not what I stored

As for "converting", first decide which case you have, then apply the given ALTER(s): http://mysql.rjweb.org/doc.php/charcoll#fixes_for_various_cases

Tentatively the 2-step ALTER may be the correct approach. However, test before applying it to production. Doing the 'wrong' Alter will leave quite a mess.

Please provide SHOW CREATE TABLE and a sample of SELECT HEX(col), col..., plus the query that was used to give the Mojibake. And SHOW VARIABLES LIKE 'char%';`

Note: For Western European languages, either utf8 or utf8mb4 would be sufficient. But you may as well go for utf8mb4.

Tonguetied answered 21/4, 2022 at 21:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.