password_option: {
PASSWORD EXPIRE [DEFAULT | NEVER | INTERVAL N DAY]
| PASSWORD HISTORY {DEFAULT | N}
| PASSWORD REUSE INTERVAL {DEFAULT | N DAY}
| PASSWORD REQUIRE CURRENT [DEFAULT | OPTIONAL]Account Management Statements
2241
}
lock_option: {
ACCOUNT LOCK
| ACCOUNT UNLOCK
}
The CREATE USER statement creates new MySQL accounts. It enables authentication,
role, SSL/TLS,
resource-limit, and password-management properties to be established for new
accounts, and controls
whether accounts are initially locked or unlocked.
To use CREATE USER, you must have the global CREATE USER privilege, or the
INSERT privilege
for the mysql system database. When the read_only system variable is enabled,
CREATE USER
additionally requires the CONNECTION_ADMIN or SUPER privilege.
CREATE USER either succeeds for all named users or rolls back and has no effect
if any error occurs.
By default, an error occurs if you try to create a user that already exists. If
the IF NOT EXISTS clause
is given, the statement produces a warning for each named user that already
exists, rather than an
error.
Important
Under some circumstances, CREATE USER may be recorded in server logs or
on the client side in a history file such as ~/.mysql_history, which means
that cleartext passwords may be read by anyone having read access to that
information. For information about the conditions under which this occurs for
the
server logs and how to control it, see Section 6.1.2.3, “Passwords and Logging”.
For similar information about client-side logging, see Section 4.5.1.3, “mysql
Logging”.
CREATE USER
'jeffrey'@'localhost' IDENTIFIED WITH mysql_native_password
BY 'new_password1',
'jeanne'@'localhost' IDENTIFIED WITH sha256_password
BY 'new_password2'
REQUIRE X509 WITH MAX_QUERIES_PER_HOUR 60
PASSWORD HISTORY 5
ACCOUNT LOCK;
评论