Get the App
SLTechnology News&Howtos  ›  Database  › 

How to deal with the problem of mysql Chinese characters

Shulou Source: shulou.com Published: 2022-05-31 15:34:13 10月25日 Update

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!

Tags: Characters Chinese hello questions processing content character sets data databases articles success value examples interests guys partners more knowledge industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Apple MariaDB vpn Shulou Technology