Reputation: 1193
I have a table named CHINESE
which has only one column NAME
.
The output of SHOW VARIABLES LIKE 'char%'
is:
+--------------------------+--------------------------------------------------------+ | Variable_name | Value | +--------------------------+--------------------------------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/local/mysql-5.1.73-osx10.6-x86_64/share/charsets/ | +--------------------------+--------------------------------------------------------+
When I run this query: INSERT INTO CHINESE VALUES ('你好')
, the values get inserted.
But, when I try to execute this query: SELECT * FROM CHINESE
, the result is:
+------+ | NAME | +------+ | ?? | +------+
The result of SELECT HEX(NAME) FROM CHINESE
is:
+-----------+ | HEX(NAME) | +-----------+ | 3F3F | +-----------+
Where am I making mistake?
Upvotes: 3
Views: 3121
Reputation: 3242
If mysql>=5.5.3, use utf8mb4 .
ALTER TABLE $tablename
CONVERT TO CHARACTER SET utf8mb4
COLLATE utf8mb4_general_ci
CREATE TABLE $tablename (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE $tablename
MODIFY $col1
VARCHAR(191)
CHARACTER SET utf8mb4;
refer: Mysql DOC: Column Character Set Conversion
Upvotes: 1
Reputation: 1210
Try the following to change the character set: SET NAMES 'big5';
Upvotes: -2