From 2a5f7247fccec0758f2a1111171467c1f5a30b07 Mon Sep 17 00:00:00 2001 From: Aolin Date: Wed, 17 Jul 2024 10:43:29 +0800 Subject: [PATCH] Update encryption and compression functions (#17988) --- .../encryption-and-compression-functions.md | 422 +++++++++++++++++- .../expressions-pushed-down.md | 2 +- password-management.md | 6 +- system-variables.md | 2 +- 4 files changed, 405 insertions(+), 27 deletions(-) diff --git a/functions-and-operators/encryption-and-compression-functions.md b/functions-and-operators/encryption-and-compression-functions.md index 69f99c66576d..06ac2b27071a 100644 --- a/functions-and-operators/encryption-and-compression-functions.md +++ b/functions-and-operators/encryption-and-compression-functions.md @@ -10,32 +10,410 @@ TiDB 支持使用 MySQL 8.0 中提供的大部分[加密和压缩函数](https:/ ## 支持的函数 -| 函数名 | 功能描述 | -|:-----------|:----------------------------| -| [`MD5()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_md5)                                                             | 计算字符串的 MD5 校验和       | -| [`PASSWORD()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_password) | 计算并返回密码字符串 | -| [`RANDOM_BYTES()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_random-bytes) | 返回随机字节向量 | -| [`SHA1()`, `SHA()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha1)                                                   | 计算 SHA-1 160 位校验和               | -| [`SHA2()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha2)                                                           | 计算 SHA-2 校验和                       | -| [`SM3()`](https://zh.m.wikipedia.org/zh-hans/SM3)                                                           | 计算 SM3 校验和(MySQL 中暂不支持该函数)           | -| [`AES_DECRYPT()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-decrypt) | 使用 AES 解密 | -| [`AES_ENCRYPT()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-encrypt) | 使用 AES 加密 | -| [`COMPRESS()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_compress) | 返回经过压缩的二进制字符串 | -| [`UNCOMPRESS()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_uncompress) | 解压缩字符串 | -| [`UNCOMPRESSED_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_uncompressed-length)                             | 返回字符串解压后的长度 | -| [`VALIDATE_PASSWORD_STRENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_validate-password-strength) | 确定密码强度 | - -## 相关系统变量 - -* [`block_encryption_mode`](/system-variables.md#block_encryption_mode) 变量设置 `AES_ENCRYPT()` 和 `AES_DECRYPT()` 所使用的加密模式。 - -* [`validate_password.*`](/system-variables.md) 变量影响 `VALIDATE_PASSWORD_STRENGTH()` 函数的行为。 +| 函数名 | 功能描述 | +|:--------------------------------------------------------------|:------------------| +| [`AES_DECRYPT()`](#aes_decrypt) | 使用 AES 解密 | +| [`AES_ENCRYPT()`](#aes_encrypt) | 使用 AES 加密 | +| [`COMPRESS()`](#compress) | 返回压缩后的二进制字符串 | +| [`MD5()`](#md5) | 计算字符串的 MD5 校验和 | +| [`PASSWORD()`](#password) | 计算并返回密码字符串 | +| [`RANDOM_BYTES()`](#random_bytes) | 返回随机字节向量 | +| [`SHA()`](#sha) | 计算 SHA-1 160 位校验和 | +| [`SHA1()`](#sha1) | 计算 SHA-1 160 位校验和 | +| [`SHA2()`](#sha2) | 计算 SHA-2 校验和 | +| [`SM3()`](#sm3) | 计算 SM3 校验和 | +| [`UNCOMPRESS()`](#uncompress) | 解压缩字符串 | +| [`UNCOMPRESSED_LENGTH()`](#uncompressed_length) | 返回字符串压缩前的长度 | +| [`VALIDATE_PASSWORD_STRENGTH()`](#validate_password_strength) | 计算密码强度 | + +### [`AES_DECRYPT()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-decrypt) + +`AES_DECRYPT(data, key [,iv])` 函数使用相同的 `key` 解密之前由 [`AES_ENCRYPT()`](#aes_encrypt) 函数加密的 `data`。 + +你可以使用系统变量 [`block_encryption_mode`](/system-variables.md#block_encryption_mode) 选择[高级加密标准 (AES)](https://zh.wikipedia.org/wiki/高级加密标准) 加密模式。 + +对于需要初始化向量的加密模式,使用 `iv` 参数设置。默认值为 `NULL`。 + +```sql +SELECT AES_DECRYPT(0x28409970815CD536428876175F1A4923, 'secret'); +``` + +``` ++----------------------------------------------------------------------------------------------------------------------+ +| AES_DECRYPT(0x28409970815CD536428876175F1A4923, 'secret') | ++----------------------------------------------------------------------------------------------------------------------+ +| 0x616263 | ++----------------------------------------------------------------------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +### [`AES_ENCRYPT()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-encrypt) + +`AES_ENCRYPT(data, key [,iv])` 函数使用[高级加密标准 (AES)](https://zh.wikipedia.org/wiki/高级加密标准) 算法和 `key` 加密 `data`。 + +你可以使用系统变量 [`block_encryption_mode`](/system-variables.md#block_encryption_mode) 选择 AES 加密模式。 + +对于需要初始化向量的加密模式,使用 `iv` 参数设置。默认值为 `NULL`。 + +```sql +SELECT AES_ENCRYPT(0x616263,'secret'); +``` + +``` ++----------------------------------------------------------------+ +| AES_ENCRYPT(0x616263,'secret') | ++----------------------------------------------------------------+ +| 0x28409970815CD536428876175F1A4923 | ++----------------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +### [`COMPRESS()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_compress) + +`COMPRESS(expr)` 函数返回输入参数 `expr` 的压缩版本。 + +- 如果输入参数为 `NULL`,该函数返回 `NULL`。 +- 如果输入参数为空字符串,该函数返回零长度值。 + +对于非零长度输入参数,函数返回具有以下结构的二进制字符串: + +- 字节 0 到 3:未压缩长度 +- 字节 4 到结尾:zlib 压缩数据 + +```sql +SELECT COMPRESS(0x414243); +``` + +``` ++------------------------------------------+ +| COMPRESS(0x414243) | ++------------------------------------------+ +| 0x03000000789C72747206040000FFFF018D00C7 | ++------------------------------------------+ +1 row in set (0.00 sec) +``` + +在此输出中,`0x03000000` 表示未压缩长度 (3),`0x789C72747206040000FFFF018D00C7` 是 zlib 压缩数据。 + +使用 Python 在 TiDB 外部解码的示例: + +```python +import codecs +import zlib + +data = codecs.decode('03000000789C72747206040000FFFF018D00C7','hex') +print(int.from_bytes(data[:4], byteorder='little')) # 3 +print(zlib.decompress(data[4:])) # b'ABC' +``` + +对于短字符串,`COMPRESS()` 可能返回比输入更多的字节。以下示例显示 100 个 `a` 字符的字符串压缩为 19 字节。 + +```sql +WITH x AS (SELECT REPEAT('a',100) 'a') +SELECT LENGTH(a),LENGTH(COMPRESS(a)) FROM x; +``` + +``` ++-----------+---------------------+ +| LENGTH(a) | LENGTH(COMPRESS(a)) | ++-----------+---------------------+ +| 100 | 19 | ++-----------+---------------------+ +1 row in set (0.00 sec) +``` + +### [`MD5()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_md5) + +`MD5(expr)` 函数为给定参数 `expr` 计算 128 位 [MD5](https://zh.wikipedia.org/wiki/MD5) 哈希值。 + +```sql +SELECT MD5('abc'); +``` + +``` ++----------------------------------+ +| MD5('abc') | ++----------------------------------+ +| 900150983cd24fb0d6963f7d28e17f72 | ++----------------------------------+ +1 row in set (0.00 sec) +``` + +### [`PASSWORD()`](https://dev.mysql.com/doc/refman/5.7/en/encryption-functions.html#function_password) + +> **警告:** +> +> `PASSWORD()` 函数在 MySQL 5.7 中已弃用,在 MySQL 8.0 中已删除,在 TiDB 中也已弃用。不建议使用此函数。 + +`PASSWORD(str)` 函数计算可用于 `mysql_native_password` 认证方法的密码哈希。 + +```sql +SELECT PASSWORD('secret'); +``` + +``` ++-------------------------------------------+ +| PASSWORD('secret') | ++-------------------------------------------+ +| *14E65567ABDB5135D0CFD9A70B3032C179A49EE7 | ++-------------------------------------------+ +1 row in set, 1 warning (0.00 sec) + +Warning (Code 1681): PASSWORD is deprecated and will be removed in a future release. +``` + +### [`RANDOM_BYTES()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_random-bytes) + +`RANDOM_BYTES(n)` 函数返回 `n` 个随机字节。 + +```sql +SELECT RANDOM_BYTES(3); +``` + +``` ++----------------------------------+ +| RANDOM_BYTES(3) | ++----------------------------------+ +| 0x1DBC0D | ++----------------------------------+ +1 row in set (0.00 sec) +``` + +### [`SHA()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha1) + +`SHA()` 函数是 [`SHA1`](#sha1) 的别名。 + +### [`SHA1()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha1) + +`SHA1(expr)` 函数为给定参数 `expr` 计算 160 位 [SHA-1](https://zh.wikipedia.org/wiki/SHA-1) 哈希值。 + +```sql +SELECT SHA1('abc'); +``` + +``` ++------------------------------------------+ +| SHA1('abc') | ++------------------------------------------+ +| a9993e364706816aba3e25717850c26c9cd0d89d | ++------------------------------------------+ +1 row in set (0.00 sec) +``` + +### [`SHA2()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha2) + +`SHA2(str, n)` 函数使用 [SHA-2](https://zh.wikipedia.org/wiki/SHA-2) 系列中的算法计算哈希值。参数 `n` 用于选择算法。如果任一参数为 `NULL` 或 `n` 指定的算法未知或不受支持,`SHA2()` 返回 `NULL`。 + +以下列出支持的算法: + +| n | 算法 | +|-----|---------| +| 0 | SHA-256 | +| 224 | SHA-224 | +| 256 | SHA-256 | +| 384 | SHA-384 | +| 512 | SHA-512 | + +```sql +SELECT SHA2('abc',224); +``` + +``` ++----------------------------------------------------------+ +| SHA2('abc',224) | ++----------------------------------------------------------+ +| 23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7 | ++----------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +### `SM3()` + +> **注意:** +> +> `SM3()` 函数是 TiDB 扩展,未在 MySQL 中实现。 + +`SM3(str)` 函数为给定参数 `str` 计算 256 位 [ShangMi 3 (SM3)](https://zh.wikipedia.org/wiki/SM3) 哈希值。 + +```sql +SELECT SM3('abc'); +``` + +``` ++------------------------------------------------------------------+ +| SM3('abc') | ++------------------------------------------------------------------+ +| 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0 | ++------------------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +### [`UNCOMPRESS()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_uncompress) + +`UNCOMPRESS(data)` 函数解压缩使用 [`COMPRESS()`](#compress) 函数压缩的数据。 + +```sql +SELECT UNCOMPRESS(0x03000000789C72747206040000FFFF018D00C7); +``` + +``` ++------------------------------------------------------------------------------------------------------------+ +| UNCOMPRESS(0x03000000789C72747206040000FFFF018D00C7) | ++------------------------------------------------------------------------------------------------------------+ +| 0x414243 | ++------------------------------------------------------------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +### [`UNCOMPRESSED_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_uncompressed-length) + +`UNCOMPRESSED_LENGTH(data)` 函数返回压缩数据的前 4 个字节,即字符串在使用 [`COMPRESS()`](#compress) 函数压缩之前的长度。 + +```sql +SELECT UNCOMPRESSED_LENGTH(0x03000000789C72747206040000FFFF018D00C7); +``` + +``` ++---------------------------------------------------------------+ +| UNCOMPRESSED_LENGTH(0x03000000789C72747206040000FFFF018D00C7) | ++---------------------------------------------------------------+ +| 3 | ++---------------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +### [`VALIDATE_PASSWORD_STRENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_validate-password-strength) + +`VALIDATE_PASSWORD_STRENGTH(str)` 函数用作 [TiDB 密码管理](/password-management.md)的一部分,它计算密码的强度并返回一个 0 到 100 之间的整数值。 + +[`validate_password.*`](/system-variables.md) 系统变量影响 `VALIDATE_PASSWORD_STRENGTH()` 函数的行为。 + +示例: + +- 要启用密码复杂度检查,将系统变量 [`validate_password.enable`](/system-variables.md#validate_passwordenable-从-v650-版本开始引入) 设置为 `ON`: + + ```sql + SET GLOBAL validate_password.enable=ON; + ``` + +- 查看密码验证相关的系统变量: + + ```sql + SHOW VARIABLES LIKE 'validate_password.%'; + ``` + + ``` + +--------------------------------------+--------+ + | Variable_name | Value | + +--------------------------------------+--------+ + | validate_password.check_user_name | ON | + | validate_password.dictionary | | + | validate_password.enable | ON | + | validate_password.length | 8 | + | validate_password.mixed_case_count | 1 | + | validate_password.number_count | 1 | + | validate_password.policy | MEDIUM | + | validate_password.special_char_count | 1 | + +--------------------------------------+--------+ + 8 rows in set (0.01 sec) + ``` + +- 检查空字符串的密码强度,返回 `0`: + + ```sql + SELECT VALIDATE_PASSWORD_STRENGTH(''); + ``` + + ``` + +--------------------------------+ + | VALIDATE_PASSWORD_STRENGTH('') | + +--------------------------------+ + | 0 | + +--------------------------------+ + 1 row in set (0.00 sec) + ``` + +- 检查短字符串 `abcdef` 的密码强度,返回 `25`: + + ```sql + SELECT VALIDATE_PASSWORD_STRENGTH('abcdef'); + ``` + + ``` + +--------------------------------------+ + | VALIDATE_PASSWORD_STRENGTH('abcdef') | + +--------------------------------------+ + | 25 | + +--------------------------------------+ + 1 row in set (0.00 sec) + ``` + +- 检查较长字符串 `abcdefghi` 的密码强度,返回 `50`。此字符串长于 [`validate_password.length`](/system-variables.md#validate_passwordlength-从-v650-版本开始引入) 的默认值: + + ```sql + SELECT VALIDATE_PASSWORD_STRENGTH('abcdefghi'); + ``` + + ``` + +-----------------------------------------+ + | VALIDATE_PASSWORD_STRENGTH('abcdefghi') | + +-----------------------------------------+ + | 50 | + +-----------------------------------------+ + 1 row in set (0.00 sec) + ``` + +- 向字符串添加大写字符不会提高密码强度: + + ```sql + SELECT VALIDATE_PASSWORD_STRENGTH('Abcdefghi'); + ``` + + ``` + +-----------------------------------------+ + | VALIDATE_PASSWORD_STRENGTH('Abcdefghi') | + +-----------------------------------------+ + | 50 | + +-----------------------------------------+ + 1 row in set (0.01 sec) + ``` + +- 向字符串添加数字也不会提高密码强度: + + ```sql + SELECT VALIDATE_PASSWORD_STRENGTH('Abcdefghi123'); + ``` + + ``` + +--------------------------------------------+ + | VALIDATE_PASSWORD_STRENGTH('Abcdefghi123') | + +--------------------------------------------+ + | 50 | + +--------------------------------------------+ + 1 row in set (0.00 sec) + ``` + +- 最后,向字符串添加特殊字符将密码强度提高到 `100`,表示密码强度很高: + + ```sql + SELECT VALIDATE_PASSWORD_STRENGTH('Abcdefghi123%$#'); + ``` + + ``` + +-----------------------------------------------+ + | VALIDATE_PASSWORD_STRENGTH('Abcdefghi123%$#') | + +-----------------------------------------------+ + | 100 | + +-----------------------------------------------+ + 1 row in set (0.00 sec) + ``` ## 不支持的函数 -* `DES_DECRYPT()`、`DES_ENCRYPT()`、`OLD_PASSWORD()` 和 `ENCRYPT()`:这些函数在 MySQL 5.7 中被废弃,并且已在 MySQL 8.0 中移除。 -* 只在 MySQL 企业版中支持的函数。见 [Issue #2632](https://github.com/pingcap/tidb/issues/2632)。 +* TiDB 不支持只在 MySQL 企业版中支持的函数。见 [Issue #2632](https://github.com/pingcap/tidb/issues/2632)。 ## MySQL 兼容性 * TiDB 不支持 `STATEMENT_DIGEST()` 和 `STATEMENT_DIGEST_TEXT()` 函数。 +* TiDB 不支持 MySQL 8.0.30 中为 [`AES_ENCRYPT()`](#aes_encrypt) 和 [`AES_DECRYPT`](#aes_decrypt) 新增的 `kdf_name`、`salt` 和 `iterations` 参数。 +* MySQL 未实现 [`SM3()`](#sm3) 函数。 \ No newline at end of file diff --git a/functions-and-operators/expressions-pushed-down.md b/functions-and-operators/expressions-pushed-down.md index c462a6d4f376..cee1886d8772 100644 --- a/functions-and-operators/expressions-pushed-down.md +++ b/functions-and-operators/expressions-pushed-down.md @@ -23,7 +23,7 @@ TiFlash 也支持[本页](/tiflash/tiflash-supported-pushdown-calculations.md) | [日期运算](/functions-and-operators/date-and-time-functions.md) | [DATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date)
[DATE_FORMAT()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format)
[DATEDIFF()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_datediff)
[DAYOFMONTH()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_dayofmonth)
[DAYOFWEEK()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_dayofweek)
[DAYOFYEAR()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_dayofyear)
[FROM_DAYS()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_from-days)
[HOUR()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_hour)
[MAKEDATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_makedate)
[MAKETIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_maketime)
[MICROSECOND()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_microsecond)
[MINUTE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_minute)
[MONTH()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_month)
[MONTHNAME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_monthname)
[PERIOD_ADD()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_period-add)
[PERIOD_DIFF()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_period-diff)
[SEC_TO_TIME()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_sec-to-time)
[SECOND()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_second)
[SYSDATE()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_sysdate)
[TIME_TO_SEC()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_time-to-sec)
[TIMEDIFF()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_timediff)
[WEEK()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_week)
[WEEKOFYEAR()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_weekofyear)
[YEAR()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_year) | | [字符串函数](/functions-and-operators/string-functions.md) | [ASCII()](/functions-and-operators/string-functions.md#ascii)
[BIT_LENGTH()](/functions-and-operators/string-functions.md#bit_length)
[CHAR()](/functions-and-operators/string-functions.md#char)
[CHAR_LENGTH()](/functions-and-operators/string-functions.md#char_length)
[CONCAT()](/functions-and-operators/string-functions.md#concat)
[CONCAT_WS()](/functions-and-operators/string-functions.md#concat_ws)
[ELT()](/functions-and-operators/string-functions.md#elt)
[FIELD()](/functions-and-operators/string-functions.md#field)
[HEX()](/functions-and-operators/string-functions.md#hex)
[LENGTH()](/functions-and-operators/string-functions.md#length)
[LIKE](/functions-and-operators/string-functions.md#like)
[LOWER()](/functions-and-operators/string-functions.md#lower)
[LTRIM()](/functions-and-operators/string-functions.md#ltrim)
[MID()](/functions-and-operators/string-functions.md#mid)
[NOT LIKE](/functions-and-operators/string-functions.md#not-like)
[NOT REGEXP](/functions-and-operators/string-functions.md#not-regexp)
[REGEXP](/functions-and-operators/string-functions.md#regexp)
[REGEXP_LIKE()](/functions-and-operators/string-functions.md#regexp_like)
[REGEXP_REPLACE()](/functions-and-operators/string-functions.md#regexp_replace)
[REGEXP_SUBSTR()](/functions-and-operators/string-functions.md#regexp_substr)
[REPLACE()](/functions-and-operators/string-functions.md#replace)
[REVERSE()](/functions-and-operators/string-functions.md#reverse)
[RIGHT()](/functions-and-operators/string-functions.md#right), [RLIKE](/functions-and-operators/string-functions.md#rlike)
[RTRIM()](/functions-and-operators/string-functions.md#rtrim)
[SPACE()](/functions-and-operators/string-functions.md#space)
[STRCMP()](/functions-and-operators/string-functions.md#strcmp)
[SUBSTR()](/functions-and-operators/string-functions.md#substr)
[SUBSTRING()](/functions-and-operators/string-functions.md#substring)
[UPPER()](/functions-and-operators/string-functions.md#upper) | | [聚合函数](/functions-and-operators/aggregate-group-by-functions.md#group-by-聚合函数) | [COUNT()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_count)
[COUNT(DISTINCT)](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_count-distinct)
[SUM()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_sum)
[AVG()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_avg)
[MAX()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_max)
[MIN()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_min)
[VARIANCE()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_variance)
[VAR_POP()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_var-pop)
[STD()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_std)
[STDDEV()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_stddev)
[STDDEV_POP](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_stddev-pop)
[VAR_SAMP()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_var-samp)
[STDDEV_SAMP()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_stddev-samp)
[JSON_ARRAYAGG(key)](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_json-arrayagg)
[JSON_OBJECTAGG(key, value)](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_json-objectagg) | -| [加密和压缩函数](/functions-and-operators/encryption-and-compression-functions.md#加密和压缩函数) | [MD5()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_md5)
[SHA1(), SHA()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha1)
[UNCOMPRESSED_LENGTH()](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_uncompressed-length) | +| [加密和压缩函数](/functions-and-operators/encryption-and-compression-functions.md#加密和压缩函数) | [MD5()](/functions-and-operators/encryption-and-compression-functions.md#md5)
[SHA1(), SHA()](/functions-and-operators/encryption-and-compression-functions.md#sha1)
[UNCOMPRESSED_LENGTH()](/functions-and-operators/encryption-and-compression-functions.md#uncompressed_length) | | [Cast 函数](/functions-and-operators/cast-functions-and-operators.md#cast-函数和操作符) | [CAST()](/functions-and-operators/cast-functions-and-operators.md#cast)
[CONVERT()](/functions-and-operators/cast-functions-and-operators.md#convert) | | [其他函数](/functions-and-operators/miscellaneous-functions.md#支持的函数) | [UUID()](/functions-and-operators/miscellaneous-functions.md#uuid) | diff --git a/password-management.md b/password-management.md index 6e8f5cbcf4ef..dc5b567e73ec 100644 --- a/password-management.md +++ b/password-management.md @@ -29,7 +29,7 @@ summary: 了解 TiDB 的用户密码管理机制。 密码复杂度策略支持以下功能: - 对采用明文方式设置用户密码的 SQL 语句(包括 `CREATE USER`、`ALTER USER`、`SET PASSWORD` ),系统会根据密码复杂度策略检查该密码,如果该密码不符合要求,则拒绝该密码。 -- 可以使用 SQL 函数 [`VALIDATE_PASSWORD_STRENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_validate-password-strength) 评估给定密码的强度。 +- 可以使用 SQL 函数 [`VALIDATE_PASSWORD_STRENGTH()`](/functions-and-operators/encryption-and-compression-functions.md#validate_password_strength) 评估给定密码的强度。 > **注意:** > @@ -131,13 +131,13 @@ ERROR 1819 (HY000): Require Password Length: 8 ### 密码强度评估函数 -使用 `VALIDATE_PASSWORD_STRENGTH()` 函数评估给定密码的强度,该函数接受一个密码参数,并返回一个从 0(弱)到 100(强)的整数。 +使用 [`VALIDATE_PASSWORD_STRENGTH()`](/functions-and-operators/encryption-and-compression-functions.md#validate_password_strength) 函数评估给定密码的强度,该函数接受一个密码参数,并返回一个从 0(弱)到 100(强)的整数。 > **注意:** > > 密码强度是基于当前已配置的密码复杂度策略进行评估的,密码复杂度配置改变后,同一个密码的评估结果可能与之前不同。 -`VALIDATE_PASSWORD_STRENGTH()` 函数使用示例如下: +[`VALIDATE_PASSWORD_STRENGTH()`](/functions-and-operators/encryption-and-compression-functions.md#validate_password_strength) 函数使用示例如下: ```sql SELECT VALIDATE_PASSWORD_STRENGTH('weak'); diff --git a/system-variables.md b/system-variables.md index f7aa0e58ee1e..f8767060fff9 100644 --- a/system-variables.md +++ b/system-variables.md @@ -312,7 +312,7 @@ mysql> SELECT * FROM t1; - 类型:枚举型 - 默认值:`aes-128-ecb` - 可选值:`aes-128-ecb`、`aes-192-ecb`、`aes-256-ecb`、`aes-128-cbc`、`aes-192-cbc`、`aes-256-cbc`、`aes-128-ofb`、`aes-192-ofb`、`aes-256-ofb`、`aes-128-cfb`、`aes-192-cfb`、`aes-256-cfb` -- 该变量用于设置 `AES_ENCRYPT()` 和 `AES_DECRYPT()` 函数的加密模式。 +- 该变量用于设置 [`AES_ENCRYPT()`](/functions-and-operators/encryption-and-compression-functions.md#aes_encrypt) 和 [`AES_DECRYPT()`](/functions-and-operators/encryption-and-compression-functions.md#aes_decrypt) 函数的加密模式。 ### `character_set_client`