[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/Coder994/JavaGuide/main/docs/database/character-set.md [Back]  [Original]

---
title: 
category: 
tag:
  - 
---


MySQL  UTF-8 **`utf8`**  **`utf8mb4`**

 **`utf8`**  emoji 



## 

 **** 

****

a0110000101100001 a"****"****

## 

 ASCIIGB2312GBKUTF-8......



- 
- 

### ASCII

**ASCII** (**A**merican **S**tandard **C**ode for **I**nformation **I**nterchange)  ASCII 

** ASCII **  ASCII 

ASCII  128  33 

 ASCII  8  bita ASCII 01100001 0  7  0  1 ASCII  1282^7

ASCII  **ASCII ** ASCII  8 bitsASCII  2562^8

![ASCII](https://img-blog.csdnimg.cn/img_convert/c1c6375d08ca268690cef2b13591a5b4.png)

### GB2312

ASCII 

GB2312  6700 GB2312 

GB2312  ASCII 1  2 

### GBK

GBK  GB2312  GB2312  20000 

GBK  K  Kuo ZhanKuo

### GB18030

GB18030  GB2312  GBK  70000 

### BIG5

BIG5  13000 

### Unicode & UTF-8



****

 UTF-8  GB2312  GB2312  C5A3 C5A3  UTF-8  

https://www.haomeili.net/HanZi/ZiFuBianMaZhuanHuan

![](https://img-blog.csdnimg.cn/836c49b117ee4408871b0020b74c991d.png)

 **** 

![](https://guide-blog-images.oss-cn-shenzhen.aliyuncs.com/javaguide/a8808cbabeea49caa3af27d314fa3c02-1.jpg)



**Unicode** 

Unicode Unicode 

 **UTF-8****8**-bit **U**nicode **T**ransformation **F**ormat UTF-16 UTF-32

UTF-8  1  4  UTF-16  2  4 UTF-32  4 

UTF-8  1  ASCII  UTF-8  ASCII 

UTF-32  UTF-8  4 

**UTF-8** 

![](https://guide-blog-images.oss-cn-shenzhen.aliyuncs.com/javaguide/1280px-Utf8webgrowth.svg.png)

## MySQL 

MySQL  UTF-8GB2312GBKBIG5

 `SHOW CHARSET` 

![](https://guide-blog-images.oss-cn-shenzhen.aliyuncs.com/javaguide/image-20211008164229671.png)

 UTF-8 



MySQL  UTF-8 

- **`utf8`**  `utf8``1-3`   `utf8`  3  emoji  4  4 
- **`utf8mb4`**  UTF-8  4  emoji 

** UTF-8 ** 

![](https://guide-blog-images.oss-cn-shenzhen.aliyuncs.com/javaguide/image-20211008164542347.png)

`emoji` MySQL `utf8mb4` `utf8` 

MySQL 5.7+

 CHARSET  `utf8` 

```sql
CREATE TABLE `user` (
  `id` varchar(66) CHARACTER SET utf8mb4 NOT NULL,
  `name` varchar(33) CHARACTER SET utf8mb4 NOT NULL,
  `phone` varchar(33) CHARACTER SET utf8mb4 DEFAULT NULL,
  `password` varchar(100) CHARACTER SET utf8mb4 DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
```

 insert 

```sql
INSERT INTO `user` (`id`, `name`, `phone`, `password`)
VALUES
	('A00003', 'guide', '181631312312', '123456');

```



```
Incorrect string value: '\xF0\x9F\x98\x98\xF0\x9F...' for column 'name' at row 1
```

## 

- Charset & Encoding https://www.cnblogs.com/skynet/archive/2011/05/03/2035105.html
- http://cenalulu.github.io/linux/character-encoding/
- Unicode-https://zh.wikipedia.org/wiki/Unicode
- GB2312-https://zh.wikipedia.org/wiki/GB_2312
- UTF-8-https://zh.wikipedia.org/wiki/UTF-8
- GB18030-: https://zh.wikipedia.org/wiki/GB_18030

Web Proxy Viewer  |  New URL  |  Original Page