ALTER TABLE logtest CONVERT to CHARACTER SET UTF8 COLLATE utf8_general_ci;
To modify the database character set:
The code is as follows:
ALTER DATABASE db_name DEFAULT CHARACTER SET character_name [COLLATE ...];
Change the default character set of the table and all character columns (Char,varchar,text) to the new character set
The code is as follows:
ALTER TABLE tbl_name CONVERT to CHARACTER SET character_name [COLLATE ...]
such as: ALTER TABLE logtest CONVERT to CHARACTER SET UTF8 COLLATE utf8_general_ci;
Just modify the default character set for the table:
The code is as follows:
ALTER TABLE tbl_name DEFAULT CHARACTER SET character_name [COLLATE ...];
such as: ALTER TABLE logtest DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;
To modify the character set of a field:
The code is as follows:
ALTER TABLE tbl_name Change c_name c_name CHARACTER SET character_name [COLLATE ...];
such as: ALTER TABLE logtest Change title title VARCHAR (CHARACTER) SET UTF8 COLLATE utf8_general_ci;
To view the database encoding:
The code is as follows:
SHOW CREATE DATABASE db_name;
To view the table encoding:
The code is as follows:
SHOW CREATE TABLE tbl_name;
To view field encodings:
The code is as follows:
SHOW full COLUMNS from Tbl_name;
Modifying the character set of a MySQL table