+1 vote
in Databases by (66.6k points)

The DEFAULT_CHARACTER_SET_NAME for the database is utf8mb4, and the DEFAULT_COLLATION_NAME is utf8mb4_general_ci. However, while storing data into the table, I wrongly used the charset latin1. As a result, non-English characters are not displayed correctly on the webpage. How to convert latin1 charset to utf8mb4 for the table.

1 Answer

+1 vote
by (365k points)
selected by
 
Best answer

You can run the following SQL to convert the charset latin1 to utf8mb4 for the column where the data is wrong.

In the SQL, replace your_table with your table name and your_column with the column name where your data has the wrong charset.

UPDATE your_table SET your_col = CONVERT(BINARY(CONVERT(your_col USING latin1)) USING utf8mb4);


...