In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to deal with the problem of mysql Chinese characters, the article is very detailed, has a certain reference value, interested friends must read it!
Problems with Chinese characters in mysql
Examples of successful changes on mysql5.1:
1. Clent and mysqld join default-character-set=utf8 in my.cnf
two。 Change the database character set
3. Create a database table character set
4. Change gbk that is compatible with Chinese
The following is a detailed process
Mysql > use mysql
Database changed
Mysql > CREATE TABLE pingfen
-> CODE VARCHAR (20)
-> ZONGHEPINGFEN Decimal (127.3)
-> DATE_INSERT DATEtime
-> NEIRONG LONGTEXT
-> JISHU Decimal (127.3)
-> ZIJIN Decimal (127.3)
-> XIAOXI Decimal (127.3)
-> HANGYE Decimal (127.3)
-> JIBEN Decimal (127.3)
-> PAIXU_TIPS Decimal (127.3)
-> DUANQI VARCHAR (100)
-> ZHONGQI VARCHAR (100)
-> CHANGQI VARCHAR (100)
-> CHENGBEN Decimal (127.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 (6pm 'Hello')
'>
'>
'> /
'>
'> 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 (6pm 'Hello')
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 (6je 'Hello 11111111111111111111')
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; change compatible Chinese 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 (6je 'Hello 11111111111111111111')
Query OK, 1 row affected (0.01sec)
Mysql > select duanqi from pingfen
+-- +
| | duanqi |
+-- +
| | |
| | |
| | Hello 111111111111111111 | |
+-- +
3 rows in set (0.00 sec)
Mysql >
The above is all the contents of the article "how to deal with mysql Chinese characters". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.