安装了mysql。
版本:5.5.28
操作系统 :ubuntu 12.10
mysql> show variables like ‘character%‘; +--------------------------+----------------------------+ | 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/share/mysql/charsets/ | +--------------------------+----------------------------+
创建一个表查看是latin1的格式,修改/etc/my.cnf
添加:
[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
/etc/init.d/mysql restart #启动不了了。
后来查得原来从5版本之后变了,需要这样修改
[client] default-character-set=utf8 [mysqld] character-set-server=utf8 /etc/init.d/mysql restart #启动成功 mysql> show variables like ‘character%‘; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+
修改成功。
时间: 2024-11-05 04:55:00