# RENAME USER

## Syntax

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

## Description

The RENAME USER statement renames existing MariaDB accounts. To use it, you must have the global [CREATE USER](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md#global-privileges) privilege or the [UPDATE](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md#table-privileges) privilege for the `mysql` database. Each account is named using the same format as for the [CREATE USER](/docs/server/reference/sql-statements/account-management-sql-statements/create-user.md) statement; for example, `'jeffrey'@'localhost'`.\
If you specify only the user name part of the account name, a host name part of `'%'` is used.

If any of the old user accounts do not exist or any of the new user accounts already exist, `ERROR 1396 (HY000)` results. If an error occurs, `RENAME USER`will still rename the accounts that do not result in an error.

For modifying an existing account, see [ALTER USER](/docs/server/reference/sql-statements/account-management-sql-statements/alter-user.md).

## Examples

```sql
CREATE USER 'donald', 'mickey';
RENAME USER 'donald' TO 'duck'@'localhost', 'mickey' TO 'mouse'@'localhost';
```

Renaming the host component of a user:

```sql
RENAME USER 'foo'@'1.2.3.4' TO 'foo'@'10.20.30.40';
```

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/rename-user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
