RENAME USER

RENAME USER is used to rename an existing user.

Synopsis

RenameUserStmt

RENAME USER - 图1

UserToUser

RENAME USER - 图2

Username

RENAME USER - 图3

  1. RenameUserStmt ::=
  2. 'RENAME' 'USER' UserToUser ( ',' UserToUser )*
  3. UserToUser ::=
  4. Username 'TO' Username
  5. Username ::=
  6. StringName ('@' StringName | singleAtIdentifier)? | 'CURRENT_USER' OptionalBraces

Examples

  1. CREATE USER 'newuser' IDENTIFIED BY 'mypassword';
  1. Query OK, 1 row affected (0.02 sec)
  1. SHOW GRANTS FOR 'newuser';
  1. +-------------------------------------+
  2. | Grants for newuser@% |
  3. +-------------------------------------+
  4. | GRANT USAGE ON *.* TO 'newuser'@'%' |
  5. +-------------------------------------+
  6. 1 row in set (0.00 sec)
  1. RENAME USER 'newuser' TO 'testuser';
  1. Query OK, 0 rows affected (0.08 sec)
  1. SHOW GRANTS FOR 'testuser';
  1. +--------------------------------------+
  2. | Grants for testuser@% |
  3. +--------------------------------------+
  4. | GRANT USAGE ON *.* TO 'testuser'@'%' |
  5. +--------------------------------------+
  6. 1 row in set (0.00 sec)
  1. SHOW GRANTS FOR 'newuser';
  1. ERROR 1141 (42000): There is no such grant defined for user 'newuser' on host '%'

MySQL compatibility

RENAME USER is expected to be fully compatible with MySQL. If you find any compatibility difference, you can report a bug.

See also