Skip to content

Latest commit

 

History

History
56 lines (34 loc) · 1.69 KB

sql-statement-create-user.md

File metadata and controls

56 lines (34 loc) · 1.69 KB
title summary aliases
CREATE USER | TiDB SQL Statement Reference
An overview of the usage of CREATE USER for the TiDB database.
/docs/v2.1/sql-statements/sql-statement-create-user/
/docs/v2.1/reference/sql/statements/create-user/

CREATE USER

This statement creates a new user, specified with a password. In the MySQL privilege system, a user is the combination of a username and the host from which they are connecting from. Thus, it is possible to create a user 'newuser2'@'192.168.1.1' who is only able to connect from the IP address 192.168.1.1. It is also possible to have two users have the same user-portion, and different permissions as they login from different hosts.

Synopsis

CreateUserStmt:

CreateUserStmt

IfNotExists:

IfNotExists

UserSpecList:

UserSpecList

UserSpec:

UserSpec

AuthOption:

AuthOption

StringName:

StringName

Examples

mysql> CREATE USER 'newuser' IDENTIFIED BY 'newuserpassword';
Query OK, 1 row affected (0.04 sec)

mysql> CREATE USER 'newuser2'@'192.168.1.1' IDENTIFIED BY 'newuserpassword';
Query OK, 1 row affected (0.02 sec)

MySQL compatibility

  • Several of the CREATE options are not yet supported by TiDB, and will be parsed but ignored.

See also