default-character-set=latin1# 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:/MySQL/MySQL Server 5.0/"#Path to the database root
datadir="D:/MySQL/MySQL Server 5.0/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=latin1
将其中的default-character-set=latin1改为default-character-set=gb2312,然后重启MYSQL,运行MySQL Command Line Client:
输入show variables like 'character_set_%';可以查看数据库的字符编码如下:mysql> show variables like 'character_set_%';
+--------------------------+-----------------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------------+
| character_set_client | gb2312 |
| character_set_connection | gb2312 |
| character_set_database | gb2312 |
| character_set_filesystem | binary |
| character_set_results | gb2312 |
| character_set_server | gb2312 |
| character_set_system | utf8 |
| character_sets_dir | D:\MySQL\MySQL Server 5.0\share\charsets
我按照这个一步步做了,可是我最后怎么还是:
+--------------------------+-----------------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------------+
| character_set_client | gb2312 |
| character_set_connection | gb2312 |
| character_set_database | uft-8 |
| character_set_filesystem | binary |
| character_set_results | gb2312 |
| character_set_server | uft-8 |
| character_set_system | utf8 |
| character_sets_dir | D:\MySQL\MySQL Server 5.0\share\charsets
还是乱码,高手帮帮我啊!
# ----------------------------------------------------------------------
#
# 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:/MySQL/MySQL Server 5.0/"#Path to the database root
datadir="D:/MySQL/MySQL Server 5.0/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=latin1
将其中的default-character-set=latin1改为default-character-set=gb2312,然后重启MYSQL,运行MySQL Command Line Client:
输入show variables like 'character_set_%';可以查看数据库的字符编码如下:mysql> show variables like 'character_set_%';
+--------------------------+-----------------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------------+
| character_set_client | gb2312 |
| character_set_connection | gb2312 |
| character_set_database | gb2312 |
| character_set_filesystem | binary |
| character_set_results | gb2312 |
| character_set_server | gb2312 |
| character_set_system | utf8 |
| character_sets_dir | D:\MySQL\MySQL Server 5.0\share\charsets
我按照这个一步步做了,可是我最后怎么还是:
+--------------------------+-----------------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------------+
| character_set_client | gb2312 |
| character_set_connection | gb2312 |
| character_set_database | uft-8 |
| character_set_filesystem | binary |
| character_set_results | gb2312 |
| character_set_server | uft-8 |
| character_set_system | utf8 |
| character_sets_dir | D:\MySQL\MySQL Server 5.0\share\charsets
还是乱码,高手帮帮我啊!
2、如果是在dos里下中文显示乱码,那么设置 character_set_results = GBK 即可
3、如果dos下中文显示正常,但把中文存入数据库后变成乱码,那是你的数据连接url中没有加上
useUnicode=true&CharacterEncoding=UTF-8
a、安装Mysql时选择UTF-8;
b、安装过后修改my.ini文件中default-character-set = UTF8;注意,这里的UTF不带“-”;
c、在client上执行 set names 'UTF8';
d、使用show variables "%char%", show variables "%collation%"分别查看character set和collation的编码都是UTF8;
e、在client上执行 set character_set_results = GBK;
f、创建数据库时,要选择对应的字符集为UTF-8重启mysql,看下是否正常显示中文
可是现在连在mysql command line client上插入中文数据都不行。