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;
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 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 hourSee other pages for examples of specific GRANT options...
REVOKE ALL PRIVILEGES ON database.* FROM myuser@%;
ALTER USER 'myuser'@'myhost.mydomain' IDENTIFIED BY RANDOM PASSWORD;
DROP USER 'myuser'@'localhost';
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