The basic usage is:
mysql> CREATE USER 'my_new_user'@'localhost' IDENTIFIED BY 'test_password';
However for situations where is not advisable to hard-code the password in cleartext it is also possible to specify directly, using the directive PASSWORD
, the hashed value as returned by the PASSWORD()
function:
mysql> select PASSWORD('test_password'); -- returns *4414E26EDED6D661B5386813EBBA95065DBC4728
mysql> CREATE USER 'my_new_user'@'localhost' IDENTIFIED BY PASSWORD '*4414E26EDED6D661B5386813EBBA95065DBC4728';