我的漫漫程序之旅

          專注于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 

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


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

          主站蜘蛛池模板: 布尔津县| 基隆市| 兰州市| 博罗县| 巴塘县| 丰台区| 荔波县| 横山县| 赣榆县| 青海省| 远安县| 湄潭县| 五莲县| 甘南县| 石泉县| 海南省| 哈密市| 石河子市| 岗巴县| 原平市| 行唐县| 新河县| 江孜县| 寿宁县| 晋州市| 安仁县| 定襄县| 宜宾县| 同江市| 大渡口区| 龙泉市| 茶陵县| 和硕县| 丹江口市| 拉孜县| 平山县| 依兰县| 福安市| 新余市| 清流县| 武平县|