Posted on 2009-08-03 11:27
疯狂 阅读(1412)
评论(0) 编辑 收藏 所属分类:
database
Mysql 字符解决:
1,安装选择utf8 编码
2,使用SHOW VARIABLES LIKE ‘character_set_%’;
显示:
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
修改my.ini中[mysqld]下的default-character-set为utf8
显示
| character_set_client | latin1
| character_set_connection | latin1
| character_set_database | utf8
| character_set_filesystem | binary
| character_set_results | latin1
| character_set_server | utf8
| character_set_system | utf8
说明此项设置The default character set that will be used when a new schema or table is
# created and no character set is defined(数据库服务器中某个库使用的字符集设定,如果建库时没有指明,将使用服务器安装时指定的字符集设置。)
但是服务端与客户端的链接字符集仍然没有修改
修改[mysql]default-character-set=utf8
显示:
| 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
客户端和服务端都统一了 ok
2: 修改你的数据库的字符编码:进入Mysql数据库,通过命令修改你的数据库字符编码: ALTER DATABASE `databaseName` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci (修改后需要重启Mysql数据库)
3: 如果你的表以及表里的字段使用了不正确的字符编码,同样需要修正过来:命令:
修改表的编码: ALTER TABLE `tableName` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
修改字段的编码: ALTER TABLE `tableName` CHANGE `dd` `dd` VARCHAR( 45 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL