MySQL: How to set a password encoded with BCrypt?

Hello Friends

With Spring Boot Client is possible use Bcrypt to encode a password as follows:

$ ./spring encodepassword superman
{bcrypt}$2a$10$3bQEwIsu2SxDxq1xafag6uH5C3TqacyI2xtQcxJqK9xyJrxgTUPkO

Therefore for a new installation of MySQL Community Server 8.4.4 in Linux the root’s password was:

  • Defined manually as plain text (for Debian/Ubuntu)
  • Generated automatically as plain text (for Fedora)

If later is need it change the root’s password is possible do the following:

mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'superman';

As you can see the new password again is a plain text

I want to know if possible do something like:

ALTER USER 'root'@'localhost' IDENTIFIED BY bcrypt('$2a$10$3bQEwIsu2SxDxq1xafag6uH5C3TqacyI2xtQcxJqK9xyJrxgTUPkO');

Of course consider the same request for a new user creation as follows:

CREATE USER 'tron'@'localhost' IDENTIFIED BY bycrypt('$2a$10...');

Question

  • How to set a password encoded with BCrypt? (for creation and alter)

Thank You

1 Like