length:占用字节char_length:共有多个字符[root@localhost][(none)]: \s--------------mysql Ver 14.14 Distrib 5.7.27, for linux-glibc2.12 (x86_64) using EditLine wrapperConnection id: 11782Current database:Current user: root@localhostSSL: Not in useCurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server version: 5.7.27-log MySQL Community Server (GPL)Protocol version: 10Connection: Localhost via UNIX socketServer characterset: utf8mb4Db characterset: utf8mb4Client characterset: utf8mb4Conn. characterset: utf8mb4UNIX socket: /mysql/tmp/mysql.sockUptime: 6 days 3 hours 38 min 4 secThreads: 2 Questions: 183301 Slow queries: 173 Opens: 8061 Flush tables: 7 Open tables: 45 Queries per second avg: 0.344--------------[root@localhost][(none)]: select length('我'),char_length('我');+---------------+--------------------+| length('我') | char_length('我') |+---------------+--------------------+| 3 | 1 |+---------------+--------------------+1 row in set (0.00 sec)转为16进制编码[root@localhost][(none)]: select hex('我');+------------+| hex('我') |+------------+| E68891 |+------------+1 row in set (0.00 sec)[root@localhost][(none)]: select 0xE68891;+----------+| 0xE68891 |+----------+| 我 |+----------+1 row in set (0.00 sec)不同字符集结果不一样[root@localhost][(none)]: set character_set_client=latin1;Query OK, 0 rows affected (0.00 sec)[root@localhost][(none)]: select length('我'),char_length('我');+-------------------+------------------------+| length('我') | char_length('我') |+-------------------+------------------------+| 7 | 3 |+-------------------+------------------------+1 row in set (0.00 sec)[root@localhost][(none)]: select hex('我');+----------------+| hex('我') |+----------------+| C3A6CB86E28098 |+----------------+1 row in set (0.00 sec)