Name
CREATE USER
Synopsis
CREATE USER 'user
'[@'host
'] [IDENTIFIED BY [PASSWORD] 'password
'] [, ...]
This statement creates new user accounts on the MySQL server.
The username is given within quotes, followed by the at
sign (@
) and a host IP address or hostname within
quotes. For accessing MySQL locally, use the host of localhost
. The IP
address is 127.0.0.1
. Use the percent sign
(%
) wildcard as the host to allow a client with the
specified username to connect from any host. If no host or
@
is given, the percent sign is assumed.
The user password is given in plain text within quotes,
preceded by the IDENTIFIED BY
clause.
You don’t need to use the PASSWORD()
function
to encrypt the password; this is done automatically. However, if you
wish to provide the hash value of the password, precede the password
with IDENTIFIED BY PASSWORD
. If the password clause
is not given, a blank password is assumed and will be accepted. This
is a potential security problem and should never be done. If you do
this by mistake, use the SET PASSWORD
statement to set the
password.
Multiple user accounts may be specified in a comma-separated list.
The CREATE USER
statement was introduced in
version 5.0.2 of MySQL. For previous versions, use the
GRANT
statement. This new statement operates similarly to the
GRANT
statement, except that you cannot specify
user privileges with the CREATE USER
statement. As
a result, the process is to create a user with the CREATE
USER
statement and then to grant the user privileges with ...
Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.