MySQL Users

Check

SELECT host,

       user,

       account_locked,

       plugin,

       password_expired,

       password_last_changed,

       password_lifetime

  FROM mysql.user;

SHOW CREATE USER user@host;

SHOW GRANTS FOR user@host;

User authentication related configuration parameters etc.
Roles & Privileges
Encrypted password data store for automatic login

CREATE

CREATE USER 'myuser'@'myhost.mydomain' IDENTIFIED BY RANDOM PASSWORD;

Generated random passwords have a length of 20 characters. This length is controlled by the generated_random_password_length system variable.This option not available in older versions of MySQL or derivatives.

If you need control over what the password will be, then use...

CREATE USER 'myuser'@'myhost.mydomain' IDENTIFIED BY 'myPassword'

GRANT

GRANT ALL PRIVILEGES ON database.* TO myuser@%;

To limit login attempts (e.g. to reduce risks of a Denial Of Service style of attack)... 

GRANT USAGE ON *.* TO 'myuser'@'myhost' WITH MAX_CONNECTIONS_PER_HOUR 50;

Limits number of connection attempts by 'myuser'@'myhost to any database to 50 per hour

See other pages for examples of specific GRANT options...

REVOKE

REVOKE ALL PRIVILEGES ON database.* FROM myuser@%;

ALTER

ALTER USER 'myuser'@'myhost.mydomain' IDENTIFIED BY RANDOM PASSWORD;

NOTE: On older versions of MySQL (5.7 and earlier) you may need to change passwords using...SET PASSWORD FOR 'myuser'@'localhost' = PASSWORD('mypassword');

DROP

DROP USER  'myuser'@'localhost';

Duplicate

Percona Toolkit

If you have the Percona Toolkit installed you can dump the CREATE statements and GRANTs for all users...

pt-show-grants --ask-pass --user root

Bibliography