为什么mysql默认为utf-8,但是CMD不能插入汉字
2013-07-14 10:06
597 查看
mysql数据库乱码问题
2009-02-19 19:16
我的mysql数据库状态如下:
--------------
D:Program FilesMySQLMySQL Server5.2binmysql.exe Ver 14.13 Distrib 5.2.0-f
alcon-alpha, for Win32 (ia32)
Connection id: 30
Current database:
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.2.0-falcon-alpha-community-nt MySQL Community Server(
GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Servercharacterset: utf8
Db characterset: utf8
Clientcharacterset: utf8
Conn.characterset: utf8
TCP port: 3306
Uptime: 6 hours 37 min 37 sec
Threads: 1 Questions: 230 Slow queries: 0 Opens:25 Flush tables: 1 Open ta
bles: 1 Queries per second avg:%
--------------
无论我用jsp页面还是servlet(而且统一为utf-8)向数据库插入中文时出现乱码,显示为:???,在cmd界面插入中文数据时出现ERROR:1366(HY000)Incorrectstring
value:,我google了很久,试了很多种方法都没用,只有一个地方说的方法有效。就是将MySQL
Server5.2中的my.ini中的CLIENT SECTION部分中的default-character-set=utf-8改为default-character-set=GBK,其他的都不变,然后重新打开mysql的cmd界面执行插入操作就ok了。
没改之前的my.ini为:
# MySQL Server Instance ConfigurationFile
#----------------------------------------------------------------------
... ...
# CLIENT SECTION
#----------------------------------------------------------------------
#
# The following options will be read by MySQLclient applications.
# Note that only client applications shipped byMySQL are guaranteed
# to read this section. If you want your ownMySQL client program to
# honor these values, you need to specify it asan option during the
# MySQL client libraryinitialization.
#
[client]
port=3306
[mysql]
default-character-set=utf8
# SERVER SECTION
#----------------------------------------------------------------------
... ...
改了之后为:
# MySQL Server Instance ConfigurationFile
#----------------------------------------------------------------------
... ...
# CLIENT SECTION
#----------------------------------------------------------------------
#
# The following options will be read by MySQLclient applications.
# Note that only client applications shipped byMySQL are guaranteed
# to read this section. If you want your ownMySQL client program to
# honor these values, you need to specify it asan option during the
# MySQL client libraryinitialization.
#
[client]
port=3306
[mysql]
default-character-set=GBK
# SERVER SECTION
#----------------------------------------------------------------------
... ...
网络上很多高手都说要jsp、servlet、mysql的编码要统一,但是统一为utf-8却会出现问题,只有这样改了才ok,至于到底原因在还请高手们多多指教。
2009-02-19 19:16
我的mysql数据库状态如下:
--------------
D:Program FilesMySQLMySQL Server5.2binmysql.exe Ver 14.13 Distrib 5.2.0-f
alcon-alpha, for Win32 (ia32)
Connection id: 30
Current database:
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.2.0-falcon-alpha-community-nt MySQL Community Server(
GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Servercharacterset: utf8
Db characterset: utf8
Clientcharacterset: utf8
Conn.characterset: utf8
TCP port: 3306
Uptime: 6 hours 37 min 37 sec
Threads: 1 Questions: 230 Slow queries: 0 Opens:25 Flush tables: 1 Open ta
bles: 1 Queries per second avg:%
--------------
无论我用jsp页面还是servlet(而且统一为utf-8)向数据库插入中文时出现乱码,显示为:???,在cmd界面插入中文数据时出现ERROR:1366(HY000)Incorrectstring
value:,我google了很久,试了很多种方法都没用,只有一个地方说的方法有效。就是将MySQL
Server5.2中的my.ini中的CLIENT SECTION部分中的default-character-set=utf-8改为default-character-set=GBK,其他的都不变,然后重新打开mysql的cmd界面执行插入操作就ok了。
没改之前的my.ini为:
# MySQL Server Instance ConfigurationFile
#----------------------------------------------------------------------
... ...
# CLIENT SECTION
#----------------------------------------------------------------------
#
# The following options will be read by MySQLclient applications.
# Note that only client applications shipped byMySQL are guaranteed
# to read this section. If you want your ownMySQL client program to
# honor these values, you need to specify it asan option during the
# MySQL client libraryinitialization.
#
[client]
port=3306
[mysql]
default-character-set=utf8
# SERVER SECTION
#----------------------------------------------------------------------
... ...
改了之后为:
# MySQL Server Instance ConfigurationFile
#----------------------------------------------------------------------
... ...
# CLIENT SECTION
#----------------------------------------------------------------------
#
# The following options will be read by MySQLclient applications.
# Note that only client applications shipped byMySQL are guaranteed
# to read this section. If you want your ownMySQL client program to
# honor these values, you need to specify it asan option during the
# MySQL client libraryinitialization.
#
[client]
port=3306
[mysql]
default-character-set=GBK
# SERVER SECTION
#----------------------------------------------------------------------
... ...
网络上很多高手都说要jsp、servlet、mysql的编码要统一,但是统一为utf-8却会出现问题,只有这样改了才ok,至于到底原因在还请高手们多多指教。
相关文章推荐
- MySql5.5 在安装时设置编码为utf-8,扔不能插入中文的问题解决
- mysql 不能插入汉字问题 设置编码方式
- 使用hibernate和mysql生成数据表时,类型为string的属性对应的数据列不能插入汉字
- 使用JMeter往Mysql中插入数据,数据时成功插入了,但是JDBC请求为什么显示的是报错状态
- MySql即使所有地方的编码格式都为utf-8时,为何还是不能正常输入和在cmd下显示
- MySql5.5 ERROR 1366 (HY000) :在安装时设置编码为utf-8,扔不能插入中文的问题解决
- 关于Java为什么配置好环境变量但是不能在命令行cmd运行javac的问题
- mysql 插入汉字 异常 Incorrect string value: '\xE8\xA7\x84\xE5\x88\x99' for column 'name'
- MySQL 命令行不能插入中文的解决办法
- 中文乱码问题 ? 原因:JSP中默认使用iso-8859-1字符编码方式,不支持中文 ? 常见的支持中文的编码方式:gb2312(常用简体汉字)、gbk(简体和繁体汉字)、utf-8 ? 解决中文乱码
- mysql 不能插入中文和显示中文
- WampServer中修改MySQL默认编码为utf-8
- mysql 数据库中不能插入' 怎么办??
- cmd可以链接mysql,但是mysql-front/navicat 1045错误解决方法
- mysql 不能插入中文
- 目标版插入模块驱动时出现version magic 与 驱动模块插入成功但是不能卸载的解决办法
- 为什么int类型字段在mysql中默认int(11) 无符号默认int(10)?
- mysql中设置字段默认为空,插入数据时会提示doesn't have a default value的解决办法
- mysql为什么默认有那么多root用户,还有用户名为空的用户?
- Django向MySQL中插入汉字出错后的解决方法