Home > Database > Mysql Tutorial > mysql中文乱码的解决

mysql中文乱码的解决

WBOY
Release: 2016-06-07 15:19:10
Original
1285 people have browsed it

mysql数据库默认的编码为latin1,而java中与其对应的则是ISO-8859-1,则有: (1)向数据库插入时,须做重写编码GBK/GB2312----ISO-8859-1 (2)从数据库取出时,须做重写编码ISO-8859-1----GBK/GB2312 或者: 两者都使用utf8编码,修改mysql的默认编码为utf8.

mysql数据库默认的编码为latin1,而java中与其对应的则是ISO-8859-1,则有:

(1)向数据库插入时,须做重写编码GBK/GB2312---->ISO-8859-1
(2)从数据库取出时,须做重写编码ISO-8859-1---->GBK/GB2312

 

或者:
两者都使用utf8编码,修改mysql的默认编码为utf8.

如何修改:

1.linux下修改mysql的编码集

(1)mysql5.0

参考 http://linux.chinaunix.net/techdoc/database/2008/03/23/986386.shtml

(2)mysql5.5

若按上述方法修改则会导致mysql启动失败,该版本解决方案如下:

修改my.cnf:

在【mysqld】配置项下添加 character-set-server=utf8 即可。

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template