|
修改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(略);
|