From 3823dab91433aab69e5984fd9a711a982bcda5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 19 Dec 2024 07:51:41 +0100 Subject: [PATCH 1/2] Remove the PASSWORD() function --- .../encryption-and-compression-functions.md | 26 +------------------ sql-statements/sql-statement-set-password.md | 21 +++++++-------- 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/functions-and-operators/encryption-and-compression-functions.md b/functions-and-operators/encryption-and-compression-functions.md index 1bb01cfda4b46..386d1cee2bdc7 100644 --- a/functions-and-operators/encryption-and-compression-functions.md +++ b/functions-and-operators/encryption-and-compression-functions.md @@ -16,7 +16,6 @@ TiDB supports most of the [encryption and compression functions](https://dev.mys | [`AES_ENCRYPT()`](#aes_encrypt) | Encrypt using AES | | [`COMPRESS()`](#compress) | Compress and return result as a binary string | | [`MD5()`](#md5) | Calculate MD5 checksum | -| [`PASSWORD()`](#password) | Calculate and return a password string | | [`RANDOM_BYTES()`](#random_bytes) | Return a random byte vector | | [`SHA()`](#sha) | Calculate an SHA-1 160-bit checksum | | [`SHA1()`](#sha1) | Calculate an SHA-1 160-bit checksum | @@ -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) - -> **Warning:** -> -> This function is deprecated in MySQL 5.7 and removed in MySQL 8.0. It is deprecated in TiDB. It is not recommended to use this function. - -The `PASSWORD(str)` function calculates a password hash that can be used with the `mysql_native_password` authentication method. - -```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) The `RANDOM_BYTES(n)` function returns `n` random bytes. @@ -426,4 +402,4 @@ Examples: * TiDB does not support the `STATEMENT_DIGEST()` and `STATEMENT_DIGEST_TEXT()` functions. * TiDB does not support the `kdf_name`, `salt`, and `iterations` arguments for [`AES_ENCRYPT()`](#aes_encrypt) and [`AES_DECRYPT`](#aes_decrypt) that MySQL added in MySQL 8.0.30. -* MySQL does not implement the [`SM3()`](#sm3) function. \ No newline at end of file +* MySQL does not implement the [`SM3()`](#sm3) function. diff --git a/sql-statements/sql-statement-set-password.md b/sql-statements/sql-statement-set-password.md index 2d3ae1e3b6e2e..c365b2192e618 100644 --- a/sql-statements/sql-statement-set-password.md +++ b/sql-statements/sql-statement-set-password.md @@ -8,11 +8,19 @@ aliases: ['/docs/dev/sql-statements/sql-statement-set-password/','/docs/dev/refe This statement changes the user password for a user account in the TiDB system database. +> **Note:** +> +> The recommended way to change passwords is via the [ALTER USER](/sql-statements/sql-statement-alter-user.md) statement like this: +> +> ```sql +> ALTER USER myuser IDENTIFIED BY 'mypassword'; +> ``` + ## Synopsis ```ebnf+diagram SetPasswordStmt ::= - "SET" "PASSWORD" ( "FOR" Username )? "=" ( stringLit | "PASSWORD" "(" stringLit ")" ) + "SET" "PASSWORD" ( "FOR" Username )? "=" stringLit ``` ## Examples @@ -35,17 +43,6 @@ mysql> SHOW CREATE USER 'newuser'; mysql> SET PASSWORD FOR newuser = 'test'; Query OK, 0 rows affected (0.01 sec) -mysql> 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) - -mysql> SET PASSWORD FOR newuser = PASSWORD('test'); -- deprecated syntax from earlier MySQL releases -Query OK, 0 rows affected (0.00 sec) - mysql> SHOW CREATE USER 'newuser'; +----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | CREATE USER for newuser@% | From 26c169a6e18c72a909e0c7885756ae02ae5c8b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 24 Dec 2024 14:10:46 +0100 Subject: [PATCH 2/2] Update sql-statements/sql-statement-set-password.md Co-authored-by: xixirangrang --- sql-statements/sql-statement-set-password.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-set-password.md b/sql-statements/sql-statement-set-password.md index c365b2192e618..4bd8de7e024f0 100644 --- a/sql-statements/sql-statement-set-password.md +++ b/sql-statements/sql-statement-set-password.md @@ -10,7 +10,7 @@ This statement changes the user password for a user account in the TiDB system d > **Note:** > -> The recommended way to change passwords is via the [ALTER USER](/sql-statements/sql-statement-alter-user.md) statement like this: +> It is recommended to change the password by using the [`ALTER USER`](/sql-statements/sql-statement-alter-user.md) statement as follows: > > ```sql > ALTER USER myuser IDENTIFIED BY 'mypassword';