Skip to content

Commit

Permalink
Remove the PASSWORD() function
Browse files Browse the repository at this point in the history
  • Loading branch information
dveeden committed Dec 19, 2024
1 parent fda8852 commit 3823dab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 37 deletions.
26 changes: 1 addition & 25 deletions functions-and-operators/encryption-and-compression-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
* MySQL does not implement the [`SM3()`](#sm3) function.
21 changes: 9 additions & 12 deletions sql-statements/sql-statement-set-password.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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@% |
Expand Down

0 comments on commit 3823dab

Please sign in to comment.