|
修改mysql安装目录下的my.ini文件. 打开找到这一行:
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
# [mysql] default-character-set=gbk mysql
客户端字符集把字符集改成gbk.
再找到这一行:
# The default character set that will be used when a new schema or table is
# created and no character set is defined default-character-set=utf8
这个是创建数据库或表时的默认字符集,用utf8处理国际化
对于以前已经创建好的非gbk字符的数据库,在mysql的安装下
的data目录下,找到你建的相应数据库,进去后找到db.opt文件
用记事本打开,内容改成下面的即可.
default-character-set=utf8 default-collation=utf8 最好用utf8,
因为gbk在处理国际化的时候依然会乱码. 最后一种方法,
你可能临时需要设定字符编码,而又不想改配置文件.
那在执行创建脚本前,加入set names gbk(或utf8)即可.
比如: set names utf8; create table user(略);
|