In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly tells you how to compile and install the character set in mysql. You can check the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here, so let's go straight to the topic. I hope that this article on how to compile and install the character set in mysql can bring you some practical help.
1. Compilation and installation of character sets
Check the format of the character set: mysql > show create table sanlang\ gateway * 1. Row * * Table: sanlangCreate Table: CREATE TABLE `sanlang` (`id` int (11) DEFAULT NULL, `name` varchar (10) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf81 row in set (0.00 sec) mysql > insert data mysql > insert into sanlang values (22 "bangs laugh") Query OK, 1 row affected (0.00 sec) Test mysql > select * from sanlang +-+-+ | id | name | +-+-+ | 1 | xiaoming | | 2 | xiaoli | 3 | tt | 4 | gg | | 22 | testdata | | 22 | Liu Haixiao | +-+-+ 6 rows in set (0.00 sec) mysql >
Change the character set test (you can see the garbled code when id is 22 after changing the character set):
Mysql > set names gbk; Query OK, 0 rows affected (0.00 sec) mysql > select * from sanlang +-+-+ | id | name | +-+-+ | 1 | xiaoming | | 2 | xiaoli | 3 | tt | 4 | gg | | 22 | testdata | | 22 | 6 rows in set (0.10 sec) mysql >
Introduction of common character sets in 2.mysql database
How to choose the appropriate character set for 3.MYSQL
1. If you deal with all kinds of words and publish them to different countries and regions, mysql says UTF-8 (three for each Chinese character). If the application needs to deal with English, only a small number of Chinese characters utf8 is better. If you only need to support Chinese, and a large amount of data, high performance requirements, optional GBK (booking field, each Chinese character occupies double bytes, English also accounts for double bytes), such as a large number of operations, comparative sorting, fixed-length character set, faster, higher performance 3. To deal with mobile Internet business, you may need to use utf8MP4 character set 4. The teacher suggested: if there is no special need, just choose the character set of utf8
4. View the system character set
Mysql > show character set Mysql > show variables like 'character_set%' +-- +-- + | Variable_name | Value | +- -+-+ | character_set_client | utf8 | # client character set | character_set_connection | utf8 | # client connection Connected with character set | character_set_database | utf8 | # database character set Specify the configuration file or create the table | character_set_filesystem | binary | # file system character set | character_set_results | utf8 | # return result character set | character_set_server | utf8 | # CVM character set Specify configuration file or build database and table | character_set_system | utf8 | # system character set | character_sets_dir | / application/mysql-5.5.49/share/charsets/ | +-- +- -+ 8 rows in set (0.00 sec) mysql >
5.set names controls the character set of the client
You can see that set names only controls the character set of the client.
Mysql > show variables like 'character_set%' +-- +-- + | Variable_name | Value | +- -+-- + | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | | character_sets_dir | / application/mysql-5.5.49/share/charsets/ | +-- +-+ 8 rows in set (0.00 sec) mysql > set name gbk | Mysql > show variables like 'character_set%' +-- +-- + | Variable_name | Value | +- -+-- + | character_set_client | gbk | | character_set_connection | gbk | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | gbk | | character_set_server | utf8 | | character_set_system | utf8 | | | character_sets_dir | / application/mysql-5.5.49/share/charsets/ | +-- +-+ 8 rows in set (0.00 sec) |
6. Unified client character set
1. ① set names utf8 method ② the following three commands replace set names (actually change the character set of client) SET character_set_client = gbkSET character_set_connection = gbkSET character_set_results = gbk method ③ login specify the character set [root@oldboy ~] # mysql-poldboy123-S / data/3306/mysql.sock-- default-character-set=utf8 Law ④ modifies the character set of the mysl client by modifying my.cnf, and takes effect permanently [client] default-character-set = utf8 # No need to restart the service, login will take effect if you log out. Note: multiple instances modify the client character set to modify / etc/my.cnf
7. Change the character set of the mysql server
Modify the my.cnf parameter [mysqld] default-character-set = utf8 # for 5.1and previous versions character-set-server = utf8 # for 5.5as required
8. Specify the character set when creating the library
Mysql > create database oldboy CHARACTER SET gbk COLLATE gbk_chinese_ci; description: specify the character set when creating the table. If you do not specify the character set, then the characters of the table and the library are the same.
9. Procedures should also be unified.
The character set of program and library table is unified.
10. Character set of the system
[root@oldboy ~] # cat / etc/sysconfig/i18nLANG= "zh_CN.UTF-8"
11. The method of executing sql statement in Database
The a.sql statement is changed to the unsigned format b. Utf8 on the windows client. Import data the format of the specified character set mysql-uroot-poldboy123-- default-character-set=utf8
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.