This documentation is for an older version. If you're using the most current version, select the documentation for that version with the version switch in the upper right corner of the online documentation, or by downloading a newer PDF or EPUB file. CREATE USER Syntax

CREATE USER user_specification [, user_specification] ...

    user [ identified_option ]

identified_option: {
    IDENTIFIED BY 'auth_string'
  | IDENTIFIED BY PASSWORD 'hash_string'

The CREATE USER statement creates new MySQL accounts. An error occurs if you try to create an account that already exists. To use this statement, you must have the global CREATE USER privilege or the INSERT privilege for the mysql database. For each account, CREATE USER creates a new row in the mysql.user table with no privileges. Depending on the syntax used, CREATE USER may also assign the account a password.

Each user_specification clause consists of an account name and information about how authentication occurs for clients that use the account. This part of CREATE USER syntax is shared with GRANT, so the description here applies to GRANT as well.

Each account name uses the format described in Section 6.2.3, “Specifying Account Names”. For example:

CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';

If you specify only the user name part of the account name, a host name part of '%' is used.

CREATE USER examples:

For additional information about setting passwords, see Section 6.3.5, “Assigning Account Passwords”.


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 password logging in the server logs, see Section, “Passwords and Logging”. For similar information about client-side logging, see Section, “mysql Logging”.

The CREATE USER statement was added in MySQL 5.0.2.