MySQL - SHOW CREATE USER Statement



MySQL SHOW CREATE USER Statement

You can create a new user account in MySQL using the CREATE USER Statement. To create a user account, the current account needs to have CREATE USER privilege, or the INSERT privilege for the MySQL system schema.

The SHOW CREATE USER Statement is displays the CREATE statement used to create the specified user.

Syntax

Following is the syntax of the SHOW CREATE USER Statement.

SHOW CREATE CREATE name

Where, name is the name of the user for which you need the create statement.

Example

Assume we have created a user using the CREATE statement as shown below −

CREATE USER exampleUser IDENTIFIED BY '123456';

Following query is retrieves/displays the CREATE statement used to create the above user. −

SHOW CREATE USER exampleUser;

Output

Following is the output of the above query −

CREATE USER for exampleUser@%
CREATE USER 'exampleUser'@'%' IDENTIFIED WITH 'caching_sha2_password' AS '$A$005eiknGyZ r]L◄T☻ .x.ycpOwCHw4U5DkqKEHmlbAB3QrvgjthpimTebHdY2' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT

Example

Assume we have created another user as −

CREATE USER 'sample'@'localhost' IDENTIFIED BY 
'MyPassword' PASSWORD EXPIRE;

Following is the SHOW CREATE USER query for the above created user −

SHOW CREATE USER 'sample'@'localhost';

Output

The above query produces the following output −

CREATE USER for sam@localhost
CREATE USER 'sam'@'localhost' IDENTIFIED WITH 'caching_sha2_password' AS '$A$005IwwzH/s[jI☼yr]]6F..JYvtfazTfdlX3WPcLORT/DvYJNHSl/xWjnX3zizI84' REQUIRE NONE PASSWORD EXPIRE ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
Advertisements