I've created a user ... but forgotten the password

mysql> create user 'blayo'@'%' identified by 'right';

Which Linux command line tool can encrypt the password the same way mysql does ?

mysql> select Password,User from mysql.user
*920018161824B14A1067A69626595E68CB8284CB | blayo |

...to be sure I use the right one

$ tool right

2 Answers 2


Just use MySQL:

select password('foo');


  • It's also super-handy how this stores your new password in clear text in both your bash history log and in your MySQL log, for easy retrieval later on. ;-) Sep 14, 2014 at 18:18

MySql uses SHA1 to hash the password in the following way and then prefix's it with a star:


The argument to the outer SHA1 must be the binary result of the inner hash for it to work properly.

source: MySQL source code and the following link:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.