关于mysql中文乱码

第一步:在sql的脚本上检查创建数据库的语句是否有设置utf8:create database shop default character set utf8;

第二步:在创建表的语句末尾加上:character set = utf8;使表格识别utf8;

第三步:因为操作系统是中文的,所以character_set_results一定要设置为gb2312,results就是你查询数据库时所得的结果。

<!-- 注意!!!这样的设置仅仅当前有效,下次打开sql还是原来的设置-->    

set character_set_client=utf8;
set character_set_connection=utf8;
set character_set_database=utf8;
set character_set_filesystem=binary;
set character_set_results=gb2312;
set character_set_server=utf8;
set character_set_system=utf8;

 

第四步:找到Mysql安装文件,找到my.ini文件,

[client]

port=3306
default-character-set = utf8

[mysql]

default-character-set = gb2312


# 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]

character-set-server=utf8

---------------------------------------------这样就是永久有效!!!!---------------------------------------------------

 

posted @ 2017-06-15 12:37  IanLan  阅读(160)  评论(0编辑  收藏  举报