Sign up ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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 | be sure I use the right one

$ tool right
share|improve this question
Please do not post the same question to multiple Stack Exchange sites. The Unix & Linux version has been answered as well, which is a waste of effort. –  Gilles Aug 6 '12 at 23:57
Forgot your password? Google it! Seriously: anytime a password is stored improperly (without salt), you're likely to be able to invert the hash with Google. –  Gilles Aug 7 '12 at 0:02

2 Answers 2

up vote 5 down vote accepted

Just use MySQL:

select password('foo');


share|improve this answer
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. ;-) –  Craig Sep 14 '14 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:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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