关于mysql中中文乱码的问题

关于mysql了中的中文乱码问题

在实际开发的过程中,我要用到数据库,对于小型的项目,我们一般采用mysql数据库就可以,但是不知道大家有没有发现,在操作mysql数据库的时候,经常会出现乱码的问题。

1.表中有数据,但是查询时,显示不出来。

出现这种情况的时候,一般是写入数据和读取数据的编码格式不一致。

mysql数据库的默认编码格式是latin1,为了方便,我们一般将mysql的默认编码格式统一设置成utf8的格式。

 

 

2.插入中文数据报错

如果要插入中问的话,必须先设置:set names gbk,否则是不能插入成功的。

 

3.修改mysql的配置文件my.ini

mysql配置文件 my.ini 设置其字符集为gbk (重启有效)

[code="ini配置文件"]#
[client]

port=3306

[mysql]

default-character-set=utf8




# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]

# The TCP/IP Port the MySQL Server will listen on
port=3306


#Path to installation directory. All paths are usually resolved relative to this.
basedir="D:/Program Files/MySQL/MySQL Server 5.1/"

#Path to the database root
datadir="D:/Program Files/MySQL/MySQL Server 5.1/Application Data/Data/"

# 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



# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值