MENU
Accounts
The predefined mysql database store account information.CREATE USER user_specification [, user_specification] ... user_specification: user [ | IDENTIFIED WITH auth_plugin [AS 'auth_string'] IDENTIFIED BY [PASSWORD] 'password' ] |
‘%’ is used, if user does not contain the host name. |
If IDENTIFIED WITH is used, the server does not assign a password. If IDENTIFIED BY is used instead, the server uses the implicit, default authentication plugin. |
auth_plugin can be mysql_native_password or sha256_password. If sha256_password is used, the old_passwords system variable must be set to 2. |
The system variable default_authentication_plugin defines the implicit, default plugin. Permitted values are mysql_native_ password (default) and sha256_password. If the implicitly assigned plugin is mysql_native_password, the old_passwords system variable must be set to 0. |
‘auth_string’ is a quoted string to pass to the plugin. |
Specify PASSWORD, if you want to avoid specifying the password in plain text and you know its hash value (the value that PASSWORD() would return). |
CREATE USER ‘janet’@’localhost’ IDENTIFIED WITH sha256_password; SET old_passwords =2; SET PASSWORD FOR ‘janet’@’localhost’ = PASSWORD(‘password’); |
SET old_passwords = 0; CREATE USER ‘ahmad’@’localhost’ IDENTIFIED BY ‘password’. |
CREATE USER ‘ali’@’localhost’ IDENTIFIED BY PASSWORD ‘*90E462C37378CED12064BB3388827D2BA3A9B689’ |
SET PASSWORD [FOR user] = { PASSWORD('cleartext password') | OLD_PASSWORD('cleartext password') | 'encrypted password' } |
If the FOR user clause is omitted, the current user’s password is set. |
ALTER USER user_specification [, user_specification] ...
user_specification: user alter_option alter_option: { PASSWORD EXPIRE | PASSWORD EXPIRE DEFAULT | PASSWORD EXPIRE NEVER | PASSWORD EXPIRE INTERVAL N DAY } |
Operations will be denied when a password expires. |
The first option, PASSWORD EXPIRE, expires an account password instantly. |
The second option, PASSWORD EXPIRE DEFAULT, expires the account after the number of days specified by the default_ password_lifetime system variable. If that system variable (default:360) is set to 0, the password never expires. |
The third option, PASSWORD EXPIRE NEVER, disables automatic password expiration. |
The fourth option, PASSWORD EXPIRE INTERVAL N DAY, causes the password to expire after N days. |
RENAME USER old_user TO new_user [, old_user TO new_user] ... |
This changes the user name. |
RENAME USER ‘jane’@’localhost’ TO ‘jean’@’localhost’; |
DROP USER user [, user] ... |
This removes a user. |