我的漫漫程序之旅

          專注于JavaWeb開發(fā)
          隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
          數(shù)據(jù)加載中……

          解決Mysql亂碼問題

          修改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 

          這個是創(chuàng)建數(shù)據(jù)庫或表時的默認字符集,用utf8處理國際化
          對于以前已經(jīng)創(chuàng)建好的非gbk字符的數(shù)據(jù)庫,在mysql的安裝下
          的data目錄下,找到你建的相應數(shù)據(jù)庫,進去后找到db.opt文件
          用記事本打開,內(nèi)容改成下面的即可.
          default-character-set=utf8 default-collation=utf8 最好用utf8,
          因為gbk在處理國際化的時候依然會亂碼. 最后一種方法,
          你可能臨時需要設定字符編碼,而又不想改配置文件.
          那在執(zhí)行創(chuàng)建腳本前,加入set names gbk(或utf8)即可.
          比如: set names utf8; create table user(略);


          posted on 2007-11-23 22:38 々上善若水々 閱讀(1052) 評論(0)  編輯  收藏 所屬分類: 數(shù)據(jù)庫

          主站蜘蛛池模板: 嘉义市| 高雄市| 大连市| 沙雅县| 屏山县| 旺苍县| 乌鲁木齐县| 抚州市| 北流市| 英吉沙县| 正阳县| 忻州市| 西安市| 镇远县| 汪清县| 大厂| 宜昌市| 宜城市| 那坡县| 克什克腾旗| 新泰市| 铜鼓县| 理塘县| 裕民县| 霍林郭勒市| 海安县| 安平县| 洛隆县| 平凉市| 濮阳市| 永修县| 龙南县| 三明市| 日照市| 涡阳县| 常熟市| 信丰县| 西丰县| 师宗县| 奉贤区| 上杭县|