Skip to main content

RENAME USER

Description

This statement is used to modify the username of a login user in seekdb.

info

You must have the global CREATE USER privilege to use this command to rename a user.

Syntax

RENAME USER
'old_user_name' TO 'new_user_name'
[,'old_user_name' TO 'new_user_name'...];

Parameters

ParameterDescription
old_user_nameThe original username.
new_user_nameThe new username. The username must be less than or equal to 16 bytes.
'old_user_name' TO 'new_user_name'The username to be modified. When modifying multiple usernames, separate them with commas (,). The permissions of the new and old users remain consistent before and after the modification.

Examples

  1. Before the modification, execute the following command to view the user.

    The result is as follows:

    SELECT user FROM mysql.user;
    +-----------+
    | user |
    +-----------+
    | root |
    | admin |
    | sqluser01 |
    | sqluser02 |
    +-----------+
    4 rows in set (0.012 sec)
  2. Execute the following command to rename the username of the sqluser01 user to obsqluser01.

    RENAME USER 'sqluser01' TO 'obsqluser01';
  3. After the modification, execute the following command to view the user. The result is as follows:

    The username of the sqluser01 user is changed to obsqluser01.

    RENAME USER 'sqluser01' TO 'obsqluser01';
    Query OK, 0 rows affected (0.131 sec)

    SELECT user FROM mysql.user;
    +-------------+
    | user |
    +-------------+
    | root |
    | admin |
    | obsqluser01 |
    | sqluser02 |
    +-------------+
    4 rows in set (0.033 sec)