如何更改mysql数据库上的字符集

时间:2011-12-06 04:25:03

标签: mysql sql

我将所有character_set_*变量转储到我的MySQL数据库中,因为我希望MySQL具有'utf8'字符集。但即使使用set names命令后,只有少数变量发生了变化。我是否正确配置了这个?

mysql> SHOW VARIABLES LIKE 'character\_set\_%';
+--------------------------+--------+
| Variable_name            | Value  |
+--------------------------+--------+
| character_set_client     | latin1 |
| character_set_connection | latin1 |
| character_set_database   | latin1 |
| character_set_filesystem | binary |
| character_set_results    | latin1 |
| character_set_server     | latin1 |
| character_set_system     | utf8   |
+--------------------------+--------+
7 rows in set (0.29 sec)

mysql> set names utf8;
Query OK, 0 rows affected (0.29 sec)

mysql> SHOW VARIABLES LIKE 'character\_set\_%';
+--------------------------+--------+
| 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   |
+--------------------------+--------+
7 rows in set (0.29 sec)

1 个答案:

答案 0 :(得分:2)

ALTER DATABASE your_db_name CHARACTER SET utf8;