Home > Database > Mysql Tutorial > body text

Mysql中文乱码问题解决_MySQL

WBOY
Release: 2016-06-01 13:51:16
Original
797 people have browsed it

安装了mysql,根据教程熟悉了基本使用,创建数据库,创建表。

然而在往表中插入中文数据时出现问题,通过C#读出来的字符为乱码,原来又是编码问题捣鬼。mysql默认编码为latin,而C#读入后默认为gbk编码,从而使得解出来的字符串为乱码。

要解决此问题还是需要从数据库上做文章,将数据库的默认编码修改为gbk即可,主要通过以下步骤

1. 修改my.ini

[mysqld]

default-character-set=gbk

[mysql]

default-character-set=gbk

2. 修改data文件夹下data.opt

default-character-set=gbk

default-collation=gbk_chinese_ci

Related labels:
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