All pages
Powered by GitBook
1 of 1

Loading...

RENAME USER

Rename existing database accounts. This guide explains how to change a user's name while preserving their current privileges and properties.

Syntax

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 privilege or the UPDATE privilege for the mysql database. Each account is named using the same format as for the 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 USERwill still rename the accounts that do not result in an error.

For modifying an existing account, see .

Examples

Renaming the host component of a user:

This page is licensed: GPLv2, originally from

RENAME USER 'foo'@'1.2.3.4' TO 'foo'@'10.20.30.40';
CREATE USER
ALTER USER
fill_help_tables.sql
CREATE USER 'donald', 'mickey';
RENAME USER 'donald' TO 'duck'@'localhost', 'mickey' TO 'mouse'@'localhost';