Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In MySQL SERVER 8.0 the PASSWORD function not working

Tags:

Error while executing the PASSWORD function in MySQL Server version 8.0.12

I have the following query:

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

I am getting this 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

like image 480
Fabio C Avatar asked Sep 13 '18 19:09

Fabio C


1 Answers

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       | +-------------------------------------------------+ 
like image 110
rayzinnz Avatar answered Sep 19 '22 15:09

rayzinnz