Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the PASSWORD() function #19731

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions functions-and-operators/encryption-and-compression-functions.md
Copy link
Collaborator

@qiancai qiancai Dec 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dveeden, may I know whether this change applies to v9.0 and later? If so, we need to mention the function removal in the v9.0 release notes as well.

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:**
>
> 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';
> ```

## 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
Loading