网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

mysql中文字符的问题怎么处理

这篇文章主要介绍MySQL中文字符的问题怎么处理,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

成都创新互联专注于清河网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供清河营销型网站建设,清河网站制作、清河网页设计、清河网站官网定制、微信小程序服务,打造清河网络公司原创品牌,更为您提供清河网站排名全网营销落地服务。

mysql中文字符的问题
mysql5.1上成功更改的例子:      
      1.在my.cnf中clent和mysqld加入default-character-set=utf8

      2. 更改数据库字符集

      3.创建数据库表字符集

      4.更改兼容中文的gbk

以下是详细过程

 

mysql> use mysql

Database changed

mysql> CREATE TABLE pingfen

    ->    (CODE VARCHAR(20),

    -> ZONGHEPINGFEN Decimal(12,3),

    -> DATE_INSERT DATEtime,

    -> NEIRONG LONGTEXT,

    -> JISHU Decimal(12,3),

    -> ZIJIN Decimal(12,3),

    -> XIAOXI Decimal(12,3),

    -> HANGYE Decimal(12,3),

    -> JIBEN Decimal(12,3),

    -> PAIXU_TIPS Decimal(12,3),

    -> DUANQI VARCHAR(100),

    -> ZHONGQI VARCHAR(100),

    -> CHANGQI VARCHAR(100),

    -> CHENGBEN Decimal(12,3),

    -> CHENGBENMIAOSHU VARCHAR(500),

    -> WURIZIJIN VARCHAR(100)

    ->    ) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8;

Query OK, 0 rows affected (0.02 sec)

 

mysql> insert into table pingfen(zonghepingfen,duanqi) values(6,'你好');

    '> ;

    '> ;

    '> /

    '> ;

    '> exit

    '> exit;

    '> by;

    '> Ctrl-C -- exit!

Aborted

[root@master yum.repos.d]# mysql -uroot

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.1.71 Source distribution

 

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql> use mysql mysql

Database changed

mysql> insert into  pingfen(zonghepingfen,duanqi) values(6,'你好');

Query OK, 1 row affected, 1 warning (0.01 sec)

 

mysql> select * from pingfen;

+------+---------------+-------------+---------+-------+-------+--------+--------+-------+------------+--------+---------+---------+----------+-----------------+-----------+

| CODE | ZONGHEPINGFEN | DATE_INSERT | NEIRONG | JISHU | ZIJIN | XIAOXI | HANGYE | JIBEN | PAIXU_TIPS | DUANQI | ZHONGQI | CHANGQI | CHENGBEN | CHENGBENMIAOSHU | WURIZIJIN |

+------+---------------+-------------+---------+-------+-------+--------+--------+-------+------------+--------+---------+---------+----------+-----------------+-----------+

| NULL |         6.000 | NULL        | NULL    |  NULL |  NULL |   NULL |   NULL |  NULL |       NULL |        | NULL    | NULL    |     NULL | NULL            | NULL      |

+------+---------------+-------------+---------+-------+-------+--------+--------+-------+------------+--------+---------+---------+----------+-----------------+-----------+

1 row in set (0.00 sec)

 

mysql> set names utf8;

Query OK, 0 rows affected (0.00 sec)

 

mysql> select * from pingfen;

+------+---------------+-------------+---------+-------+-------+--------+--------+-------+------------+--------+---------+---------+----------+-----------------+-----------+

| CODE | ZONGHEPINGFEN | DATE_INSERT | NEIRONG | JISHU | ZIJIN | XIAOXI | HANGYE | JIBEN | PAIXU_TIPS | DUANQI | ZHONGQI | CHANGQI | CHENGBEN | CHENGBENMIAOSHU | WURIZIJIN |

+------+---------------+-------------+---------+-------+-------+--------+--------+-------+------------+--------+---------+---------+----------+-----------------+-----------+

| NULL |         6.000 | NULL        | NULL    |  NULL |  NULL |   NULL |   NULL |  NULL |       NULL |        | NULL    | NULL    |     NULL | NULL            | NULL      |

+------+---------------+-------------+---------+-------+-------+--------+--------+-------+------------+--------+---------+---------+----------+-----------------+-----------+

1 row in set (0.00 sec)

 

mysql> select duanqi from pingfen;

+--------+

| duanqi |

+--------+

|        |

+--------+

1 row in set (0.00 sec)

 

mysql> insert into  pingfen(zonghepingfen,duanqi) values(6,'你好111111111111111111');

Query OK, 1 row affected, 1 warning (0.01 sec)

 

mysql> commit;

Query OK, 0 rows affected (0.00 sec)

 

mysql> select duanqi from pingfen;

+--------+

| duanqi |

+--------+

|        |

|        |

+--------+

2 rows in set (0.00 sec)

 

mysql> set names gbk;

Query OK, 0 rows affected (0.00 sec)

 

mysql> select duanqi from pingfen;

+--------+

| duanqi |

+--------+

|        |

|        |

+--------+

2 rows in set (0.00 sec)

 

mysql> alter table pingfen character set gbk;    更改兼容中文的gbk

Query OK, 2 rows affected (0.07 sec)

Records: 2  Duplicates: 0  Warnings: 0

 

mysql> select duanqi from pingfen;

+--------+

| duanqi |

+--------+

|        |

|        |

+--------+

2 rows in set (0.00 sec)

 

mysql> insert into  pingfen(zonghepingfen,duanqi) values(6,'你好111111111111111111');

Query OK, 1 row affected (0.01 sec)

 

mysql> select duanqi from pingfen;

+------------------------+

| duanqi                 |

+------------------------+

|                        |

|                        |

|你好111111111111111111     |

+------------------------+

3 rows in set (0.00 sec)

 

mysql>

以上是“mysql中文字符的问题怎么处理”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!


新闻标题:mysql中文字符的问题怎么处理
分享链接:http://bjjierui.cn/article/jsoojp.html

其他资讯