在MySQL中更改变量

时间:2012-09-04 09:21:53

标签: mysql character-encoding

在MySQL中,如何更改变量,例如character_set_client?

mysql> show variables like 'character_set%';
-------------------------+-------
character_set_client     | latin1

获取

character_set_client     | utf8

1 个答案:

答案 0 :(得分:0)

启动MySQL客户端时,您必须指定--default-character-set=charset_name

来自manual

       Use charset_name as the default character set for the client and
       connection.

       A common issue that can occur when the operating system uses utf8
       or another multi-byte character set is that output from the mysql
       client is formatted incorrectly, due to the fact that the MySQL
       client uses the latin1 character set by default. You can usually
       fix such issues by using this option to force the client to use the
       system character set instead.

例如:

$>mysql -uUser -pPassword --default-character-set=utf8

有关如何通过连接字符串设置它的示例,请参阅here