In MySQL SERVER 8.0 the PASSWORD function not working

后端 未结 2 747
清歌不尽
清歌不尽 2020-12-03 17:44

Error while executing the PASSWORD function in MySQL Server version 8.0.12

I have the following query:

SELECT * 
FROM users 
WHERE login         


        
相关标签:
2条回答
  • 2020-12-03 18:28

    OP's MySQL Server version is 8.0.12. From MySQL Documentation, PASSWORD function has been deprecated for version > 5.7.5:

    Note

    The information in this section applies fully only before MySQL 5.7.5, and only for accounts that use the mysql_native_password or mysql_old_password authentication plugins. Support for pre-4.1 password hashes was removed in MySQL 5.7.5. This includes removal of the mysql_old_password authentication plugin and the OLD_PASSWORD() function. Also, secure_auth cannot be disabled, and old_passwords cannot be set to 1.

    As of MySQL 5.7.5, only the information about 4.1 password hashes and the mysql_native_password authentication plugin remains relevant.

    Instead, of the PASSWORD function, you can use much better and secure encryption functions from here. More details from the MySQL server team can be seen here.

    0 讨论(0)
  • 2020-12-03 18:42

    If you need a replacement hash to match the password() function, use this: SHA1(UNHEX(SHA1())); E.g.

    mysql> SELECT PASSWORD('mypass');
    +-------------------------------------------+
    | PASSWORD('mypass')                        |
    +-------------------------------------------+
    | *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4 |
    +-------------------------------------------+
    

    and replacement that gives the same answer in version 8:

    mysql> SELECT CONCAT('*', UPPER(SHA1(UNHEX(SHA1('mypass')))));
    +-------------------------------------------------+
    | CONCAT('*', UPPER(SHA1(UNHEX(SHA1('mypass'))))) |
    +-------------------------------------------------+
    | *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4       |
    +-------------------------------------------------+
    
    0 讨论(0)
提交回复
热议问题