订阅所有JSP/Servlet的日志 订阅 | 这是最新一篇日志 上一篇 | 下一篇日志 下一篇 ]
技术角度

关于Mysql的中文解决方案

我一个新来的同事,问我个问题:
说,他装了个Mysql但是使用中文就一直是乱码怎么都调不对,十分苦恼。
偶便答之:Google / Baidu
那同事忙说,搜了很多,但是都怪怪的,很多都不好用。
偶瀑布汗 >_<"
于是乎帮他调好,但转念一想,还是写个贴,帮助下大众吧。
于是乎,便有了下文:
-------------------------------------
MySql数据库中文乱码解决办法

例子用utf8编码说明,如果需要其他编码,请自行配置

一、数据库编码配置

1、安装版Mysql(MySql4之后版本)

安装之后,运行配置向导。运行方式2种,
A、安装之后会自动跳到;
B、运行启动->程序->MySQL->MySQL->MySQL Server[这里是版本号]->Server Instance Config Wizard(就是运行这个鬼)
注意:如果是已经配置过的,需要先选择Remove来将当前的数据库服务停止,然后才能进入配置向导。

启动之后,选择Detailed Configuration(详细设置)
后面的基本上都是默认就可以了,除非你会配(如果会配的估计也不会看我这帖子了)

直到看到3个选项,分别是
Standard Character Set (这个是默认选项,数据库编码是该死的latin1,也就是造成乱码的罪魁祸首
Best Support For Multilingualism (UTF8为默认编码,支持多语言)
Manual Selected Default Character Set / Collation (最强的自定义编码,里面自己选吧,什么Gb2312,gbk统统都有)

然后就下一步去配置什么登陆密码,然后就不用我说了。

2、非安装版数据库

在Mysql的安装目录下会有一个叫做:my.ini的配置文件,上面安装版的配置工具就是用来配置这里的。

我们用一个文本编辑器打开文件。搜索
default-character-set=
这个就是配置的默认编码啦,会有2个位置有这个出现,都要改哦。

改好了,就保存,重启数据库。

二、代码方面配置

1、如果你有中文数据是硬编码到类了,那么请将你的Java文件的编码改为utf8
2、Web应用的话,请将页面的编码也定为utf-8
3、加载过滤器,编码为utf-8

4、写数据库连接的URL的时候,后面加载一句话:
jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=utf-8
这句话就是说,在你连接Mysql的时候用的是用utf-8方式编码数据。

就是因为很多人配置不正确,因此导致数据库和代码之间的编码不统一导致数据无法正确显示。

很多人都会在编码之类的地方卡住,我一直不很理解其中的奥秘。
编码无非就是两个人说话,都说对方能听懂的语言才不出错嘛,双方统一,什么问题都解决了。
望看到我这贴的朋友以后碰到这类问题,先想,再分析,再解决,呵呵~
其实很多时候,这些事不用求人的~

平均得分
(0 次评分)





文章来自: 本站原创
标签:
评论: 8 | 查看次数: 1215
  • 共有 8 条评论
游客 [2008-12-16 17:05:57]
术+术:可能是唯一有可能冲上2300的同职业组合,天赋一般选用双恶魔法+贼:控制+爆发型,法师的爆发力略胜术士,不过容错性非常小,游戏相似组合还有法+野D,法+暗牧法+法:双冰法控制,综合来说还不错,续战力也存活能力也很强。双奥法的秒杀流一经提出就被喷的面目全非,我本人其实尝试过这个组合,可惜装备只有S2,法伤最多也只能撑到102X(现在能高不少),魔兽队友情况也差不多。这样的组合容错性低的离谱,虽然有10000+HP 400+韧性,但是感觉一被打就瞬间死,而且跑还跑不掉,所以这个打法还是更适合高端副本装,反正一样死很快。组合上还是克死战士队,别和我提盾反,网络游戏那么明显的动画效果能吸到个火冲不错了。网游基本上能够硬顶过我们5秒的职业只有骑士,冰法,盗贼和恶魔SS了。打盗贼队伍,如果是盗贼+看的见,一律先把看的见的OOXX了,双盗贼很难打,2斗篷我们免费网络游戏直接去一人。最后被一个队恶魔SS+骑士卡住了,因为奥法的后续爆发几乎没有,开局秒恶魔SS和骑士都不成功。感觉装备足够猛的话,2000是没问题的,2000以后看能否连好沉默来秒SS了。法伤最好是NOBUFF 1200+以上,最新网游保证秒杀的成功率,可以不用考虑血和韧性,建议装备牛B的法师们平时娱乐使用,非常畅快的战斗贼+暗牧:爆发力非常强的组合,而且他们的视频里很不厚道的最新免费网络游戏吃了金童3场贼+野D:第一赛季闷+盲+消失补闷+飓风的完美控制秒杀型队伍,不过在徽章能解所有控制技能之后容错性大大降低了。
游客 [2008-12-10 17:32:26]
术+术:可能是唯一有可能冲上2300的同职业组合,天赋一般选用双恶魔法+贼:控制+爆发型,法师的爆发力略胜术士,不过容错性非常小,游戏相似组合还有法+野D,法+暗牧法+法:双冰法控制,综合来说还不错,续战力也存活能力也很强。双奥法的秒杀流一经提出就被喷的面目全非,我本人其实尝试过这个组合,可惜装备只有S2,法伤最多也只能撑到102X(现在能高不少),魔兽队友情况也差不多。这样的组合容错性低的离谱,虽然有10000+HP 400+韧性,但是感觉一被打就瞬间死,而且跑还跑不掉,所以这个打法还是更适合高端副本装,反正一样死很快。组合上还是克死战士队,别和我提盾反,网络游戏那么明显的动画效果能吸到个火冲不错了。网游基本上能够硬顶过我们5秒的职业只有骑士,冰法,盗贼和恶魔SS了。打盗贼队伍,如果是盗贼+看的见,一律先把看的见的OOXX了,双盗贼很难打,2斗篷我们免费网络游戏直接去一人。最后被一个队恶魔SS+骑士卡住了,因为奥法的后续爆发几乎没有,开局秒恶魔SS和骑士都不成功。感觉装备足够猛的话,2000是没问题的,2000以后看能否连好沉默来秒SS了。法伤最好是NOBUFF 1200+以上,最新网游保证秒杀的成功率,可以不用考虑血和韧性,建议装备牛B的法师们平时娱乐使用,非常畅快的战斗贼+暗牧:爆发力非常强的组合,而且他们的视频里很不厚道的最新免费网络游戏吃了金童3场贼+野D:第一赛季闷+盲+消失补闷+飓风的完美控制秒杀型队伍,不过在徽章能解所有控制技能之后容错性大大降低了。
hhygr11jxx [2008-12-10 10:27:22]
游客 [2008-07-21 16:43:27]
游客 [2008-07-08 17:07:36]
Tyrande is the High Priestess of the moon goddess. world of warcraft power leveling Elune. She has served as the leader of the night . mp3 playerself Sentinels for nearly ten thousand years. mp3 playerbut her long vigil has left . cheap wow power leveling An exceptional and fearless warrior.. mp3 players she stands as one of the greatest heroes in recorded history. mp3 playerFollowing the catastrophic invasion of the Burning Legion. cheap world of warcraft power leveling Tyrande ruled over her people alongside her mate. mp3 players the Arch-Druid Malfurion Stormrage. mp3 player until he disappeared into the mystic Emerald Dream. level wowThe rage proc isn’t all that big a deal. wow po but four mobs and 5/5 Shield Spec. or wow means you can proc revenge almost every time its cooldown is up. wow lvl which reduces your rage consumption. wow fr and boosts your threat per second at the same time. mp4 playerWith Malfurion inexplicably lost. level wow Tyrande has again become the sole ruler of her prideful people. cheap mp3 players Troubled by Malfurion's disappearance. cheap mp3 player she nevertheless strives to keep the night. wow lvl elves from reliving the mistakes of the past. mp3 mp4 player The greatest druid ever to live. portabel mp3 player and arguably one of the most powerful beings in history. wow powerlevel Malfurion Stormrage stands as both prophet and savior to his people. mp3 playerUnder the leadership of Tyrande and Malfurion. mp3 playersthe night elves vanquished the Burning Legion not once.
游客 [2008-07-08 17:05:57]
Here is what prot is. wow gold It is for any warrior who wants towow gold kick out as much threat as his class can possibly kick out. wow gold kaufen I can run through the math world of warcraft goldwith you using any gear. wow geld but I defy you towow powerlevel with a profile that generates more threat using wow gold arms or fury than an identical profile specced prot. wow A warning, though. it is possible to build wow golda prot spec that turns you into little more than a turtle. wow gold kaufen If you build one of those.serveur wowtaking all the obvious mitigation talents. wow europe my guess is that prot will disappoint you. wow On the other hand. wow power levelingif you load up on the threat-enhancing talents. wow powerleveling I think you’ll be surprised what you can do. wow gold Improved Bloodrage.mp3 playersAt 2/2 gives you an extra 6 rage from your bloodrage ability. mp3 player I consider this a must-have.wow gold paypal A warrior without rage is like a paladin without mana. mp3 player and it’s surprising how fast a fight can spiral out of control zubehoer mp3 player if you spend just a few seconds out of your global CD. wow power leveling This can be either a quick shot in the arm of rage mp3 mid-fight or extra rage at the start of a fight if you can’t start the pull by charging. mp4Shield Specialization.
游客 [2008-07-08 17:05:12]
I started playing a year ago and have become custodian of We Know, buy wow gold a guild of about 250 people worldwide: lecteur mp3 medics, CEOs, bartenders, mothers, soldiers, students. mp4 player We assemble in-game to mount epic six-hour raids cheap wow gold that require some members to wake at 4 am mp3 and others to stay up all night. mp4 Outside the game, we stay in touch using online forums, sell wow gold a wiki, blogs, and a mailing list – plus a group voice chat, mp4 player which I’ve connected to my home stereo mp3 so I can hear the guild’s banter while I’m cooking dinner. buy cheap wow gold I have never been this addicted to anything before. mp4 My other hobbies are gone. mp4 player My daily blogging regimen has taken a hit. buy world of warcraft gold And my social life revolves more mp3 and more around friends in the game. mp4MMORPGs are not new gold wow– I played one of the first through wow gold kauf the Essex University computer network in the early 1980s. wowgold Back then, everything was text, wow po and MMORPGs were a nerdy subculture of the wow powerleveling then-minuscule online world. wow powerleveling But Blizzard synthesized the accomplishments power leveling of all past role-playing games powerleveling and added the rich gameplay wow power leveling and narratives of its previous Warcraft games.
游客 [2008-06-12 16:56:32]
  • 共有 8 条评论
发表评论
昵 称:  登录
内 容:
选 项:
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启