Update MySQL username

This function renames a MySQL® database user.

Important:

When you disable the MySQL role and remote MySQL is not already configured, the system disables this function.

SecurityBasicAuth
Request
query Parameters
newname
required
string

The user's new name.

Important:

To learn more about database username limits, check your database type:

MySQL 5.6

MySQL version 5.6 limits the database username to 16 characters. The server uses the first nine characters of this limit for the database prefix. The database prefix uses the cPanel account's username and an underscore (_). The server only applies the first eight characters of the cPanel account's username.

For example:

  • A db_ database prefix allows MySQL usernames of up to 13 characters.
  • An example_ database prefix allows MySQL usernames of up to eight characters.

MySQL 5.7+

MySQL versions 5.7 and later limit the database username to 32 characters. The server uses the first nine characters of this limit for the database prefix. The database prefix uses the cPanel account's username and an underscore (_). The server only applies the first eight characters of the cPanel account's username.

For example:

  • A db_ database prefix allows MySQL usernames of up to 29 characters.
  • An example_ database prefix allows MySQL usernames of up to 24 characters.

MariaDB

MariaDB limits the database username to 47 characters. The server uses the first nine characters of this limit for the database prefix. The database prefix uses the cPanel account's username and an underscore (_). The server only applies the first eight characters of the cPanel account's username.

For example:

  • A db_ database prefix allows MariaDB usernames of up to 44 characters.
  • An example_ database prefix allows MariaDB usernames of up to 39 characters.
Example: newname=mynewusername
oldname
required
string

The user's current name.

Example: oldname=dbuser
Responses
200

HTTP Request was successful.

Response Schema: application/json
apiversion
integer

The version of the API.

func
string

The name of the method called.

module
string

The name of the module called.

object
get/Mysql/rename_user
Request samples
uapi --output=jsonpretty \
  --user=username \
  Mysql \
  rename_user \
  oldname='dbuser' \
  newname='mynewusername'
Response samples
application/json
{
  • "apiversion": 3,
  • "func": "rename_user",
  • "module": "Mysql",
  • "result": {
    • "data": null,
    • "errors": null,
    • "messages": null,
    • "metadata": { },
    • "status": 1,
    • "warnings": null
    }
}