diff --git a/functions-and-operators/encryption-and-compression-functions.md b/functions-and-operators/encryption-and-compression-functions.md index 06ac2b27071a..4b822da7b863 100644 --- a/functions-and-operators/encryption-and-compression-functions.md +++ b/functions-and-operators/encryption-and-compression-functions.md @@ -16,7 +16,6 @@ TiDB 支持使用 MySQL 8.0 中提供的大部分[加密和压缩函数](https:/ | [`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 位校验和 | @@ -139,29 +138,6 @@ SELECT MD5('abc'); 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` 个随机字节。 diff --git a/sql-statements/sql-statement-set-password.md b/sql-statements/sql-statement-set-password.md index 8613eb3d1337..49ea15444d7e 100644 --- a/sql-statements/sql-statement-set-password.md +++ b/sql-statements/sql-statement-set-password.md @@ -8,17 +8,23 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-set-password/','/docs-cn/de `SET PASSWORD` 语句用于更改 TiDB 系统数据库中的用户密码。 +> **注意:** +> +> 建议使用 [`ALTER USER`](/sql-statements/sql-statement-alter-user.md) 语句更改密码,如下所示: +> +> ```sql +> ALTER USER myuser IDENTIFIED BY 'mypassword'; +> ``` + ## 语法图 ```ebnf+diagram SetPasswordStmt ::= - "SET" "PASSWORD" ( "FOR" Username )? "=" ( stringLit | "PASSWORD" "(" stringLit ")" ) + "SET" "PASSWORD" ( "FOR" Username )? "=" stringLit ``` ## 示例 -{{< copyable "sql" >}} - ```sql SET PASSWORD='test'; ``` @@ -27,8 +33,6 @@ SET PASSWORD='test'; Query OK, 0 rows affected (0.01 sec) ``` -{{< copyable "sql" >}} - ```sql CREATE USER 'newuser' IDENTIFIED BY 'test'; ``` @@ -37,8 +41,6 @@ CREATE USER 'newuser' IDENTIFIED BY 'test'; Query OK, 1 row affected (0.00 sec) ``` -{{< copyable "sql" >}} - ```sql SHOW CREATE USER 'newuser'; ``` @@ -52,8 +54,6 @@ SHOW CREATE USER 'newuser'; 1 row in set (0.00 sec) ``` -{{< copyable "sql" >}} - ```sql SET PASSWORD FOR 'newuser' = 'test'; ``` @@ -62,35 +62,6 @@ SET PASSWORD FOR 'newuser' = 'test'; Query OK, 0 rows affected (0.01 sec) ``` -{{< copyable "sql" >}} - -```sql -SHOW CREATE USER 'newuser'; -``` - -``` -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| CREATE USER for newuser@% | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| CREATE USER 'newuser'@'%' IDENTIFIED WITH 'mysql_native_password' AS '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.00 sec) -``` - -{{< copyable "sql" >}} - -```sql -SET PASSWORD FOR 'newuser' = PASSWORD('test'); -``` - -上述语法是早期 MySQL 版本的过时语法。 - -``` -Query OK, 0 rows affected (0.00 sec) -``` - -{{< copyable "sql" >}} - ```sql SHOW CREATE USER 'newuser'; ```