This is a read-only copy of the MariaDB Knowledgebase generated on 2024-12-22. For the latest, interactive version please visit https://mariadb.com/kb/.

RENAME USER

语法

RENAME USER old_user TO new_user
    [, old_user TO new_user] ...

描述

RENAME USER 语句用于重命名现有的 MariaDB 帐户。要使用它,您必须拥有全局 CREATE USER 权限或者对 mysql 数据库的 UPDATE 权限。每个帐户的命名格式与 CREATE USER 语句相同,例如 'jeffrey'@'localhost'。如果您只指定帐户名称的用户部分,则使用主机名部分为 '%'

如果任何旧用户帐户不存在或任何新用户帐户已经存在,则会出现 ERROR 1396 (HY000)。如果出现错误,则 RENAME USER 仍会重命名不会出错的帐户。

示例

CREATE USER 'donald', 'mickey';
RENAME USER 'donald' TO 'duck'@'localhost', 'mickey' TO 'mouse'@'localhost';
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.