mysql convert a column to utf-8

You can use this mysql query code:

ALTER TABLE yourtable MODIFY
    yourcol VARCHAR(255)
      CHARACTER SET utf8
      COLLATE utf8_general_ci;

There are more problems with ENUM and SET type fields.

For ENUM you have to specify all the field values, no matter how many they are

ALTER TABLE yourtable MODIFY
    yourcol ENUM('val1','val2',etc)
      CHARACTER SET utf8
      COLLATE utf8_general_ci;

For SET the problems rise from the name SET, so you have to do this command

ALTER TABLE yourtable MODIFY
    yourcol CHAR(255)
      CHARACTER SET utf8
      COLLATE utf8_general_ci;

You will be able afterwards to modify CHAR to SET (with your previous values) without losing your data.

Lascia un commento

Il tuo indirizzo email non sarà pubblicato.