MySql表、字段、库的字符集修改及查看方法
修改数据库字符集:
ALTERDATABASEdb_nameDEFAULTCHARACTERSETcharacter_name[COLLATE...];
把表默认的字符集和所有字符列(CHAR,VARCHAR,TEXT)改为新的字符集:
ALTERTABLEtbl_nameCONVERTTOCHARACTERSETcharacter_name[COLLATE...]
如:ALTERTABLElogtestCONVERTTOCHARACTERSETutf8COLLATEutf8_general_ci;
只是修改表的默认字符集:
ALTERTABLEtbl_nameDEFAULTCHARACTERSETcharacter_name[COLLATE...];
如:ALTERTABLElogtestDEFAULTCHARACTERSETutf8COLLATEutf8_general_ci;
修改字段的字符集:
ALTERTABLEtbl_nameCHANGEc_namec_nameCHARACTERSETcharacter_name[COLLATE...];
如:ALTERTABLElogtestCHANGEtitletitleVARCHAR(100)CHARACTERSETutf8COLLATEutf8_general_ci;
查看数据库编码:
SHOWCREATEDATABASEdb_name;
查看表编码:
SHOWCREATETABLEtbl_name;
查看字段编码:
SHOWFULLCOLUMNSFROMtbl_name;