Home > Database > Mysql Tutorial > What is the replacement for the deprecated PASSWORD function in MySQL Server 8.0?

What is the replacement for the deprecated PASSWORD function in MySQL Server 8.0?

Barbara Streisand
Release: 2024-10-29 02:51:30
Original
403 people have browsed it

What is the replacement for the deprecated PASSWORD function in MySQL Server 8.0?

PASSWORD Function Discontinuation in MySQL Server 8.0

In MySQL Server version 8.0, the PASSWORD function has been deprecated and no longer operates as intended. This issue arises when executing queries that rely on the PASSWORD function for password validation.

Error Message

When executing a query that includes the PASSWORD function in MySQL Server version 8.0.12, you may encounter the following error:

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near...
Copy after login

Replacement for PASSWORD Function

To resolve this issue, it is recommended to use the following expression as a replacement for the PASSWORD function:

SHA1(UNHEX(SHA1()))
Copy after login

Example

For instance, if you previously had a query like:

SELECT * 
FROM users 
WHERE login = 'FABIO' 
AND pwd = PASSWORD('2018') 
LIMIT 0, 50000
Copy after login

You can replace the PASSWORD function with the expression:

SELECT * 
FROM users 
WHERE login = 'FABIO' 
AND pwd = SHA1(UNHEX(SHA1('2018'))) 
LIMIT 0, 50000
Copy after login

By using the provided replacement expression, you can ensure that your queries continue to function correctly in MySQL Server version 8.0 and avoid the error mentioned above.

The above is the detailed content of What is the replacement for the deprecated PASSWORD function in MySQL Server 8.0?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template