MySQL charset - von latin nach utf-8

Aus Wikizone
Wechseln zu: Navigation, Suche

Der Trick ist zuerst einen Binären Datentyp zu nehmen.

Achtung beim zurückwandeln in einen Texttyp, daß man hier den richtigen Typ nimmt (varchar oder text oder char) sonst werden evtl. Zeichen abgeschnitten.

alter database... ist nur notwendig wenn die db noch nicht auf utf-8 steht


alter table TABLE_NAME modify FIELD_NAME blob;
alter database DATABASE_NAME charset=utf8;
alter table TABLE_NAME modify FIELD_NAME varchar(255) character set utf8;

Wenn das Feld schon utf-8 ist aber die Daten noch in latin muß man zuerst zurück nach latin

alter table TABLE_NAME modify FIELD_NAME varchar(255) character set latin1;
alter table TABLE_NAME modify FIELD_NAME blob;
alter table TABLE_NAME modify FIELD_NAME varchar(255) character set utf8;