---
title: "Update MySQL database name"
method: GET
path: "/Mysql/rename_database"
tags: ["Mysql", "Database Management"]
---

# Update MySQL database name

`GET /Mysql/rename_database`

This function renames a MySQL® database.

MySQL does not allow you to rename a database. When cPanel & WHM "renames" a database, the
system performs the following steps:
1. The system creates a new database.
2. The system moves data from the old database to the new database.
3. The system recreates grants and stored code in the new database.
4. The system deletes the old database and its grants.

**Warning:**

* It is potentially dangerous to rename a MySQL database. We **strongly** recommend that you
perform a backup of the database before you attempt to rename it.
* If any of the first three steps fail, the system returns an error and attempts to restore the database's original state.
 If the restoration process fails, the API function's error response describes these additional failures.
* In rare cases, the system creates the second database successfully, but fails to delete the old database or grants.
 The system treats the rename action as a success; however,
 the API function returns warnings that describe the failure to delete the old database or grants.

**Important:**

When you disable the [MySQL/MariaDB role](https://go.cpanel.net/serverroles)
**and** remote MySQL is **not** already configured, the system **disables** this function.

## Query parameters

- `newname` string, required
- `oldname` string, required

## Response `200`

HTTP Request was successful.

- object
  - `apiversion` integer — The version of the API.
  - `func` string — The name of the method called.
  - `module` string — The name of the module called.
  - `result` object
    - `data` object, nullable
    - `errors` string[], nullable — List of errors if the API failed.
    - `messages` string[], nullable — List of messages generated by the API.
    - `metadata` object
    - `status` 0 | 1 — * `1` - Success * `0` - Failed: Check the errors field for more details.
    - `warnings` string[], nullable — List of warnings generated by the API. Warnings describe non-critical failures or other problematic conditions noted while running a API.

---

[API](https://skmtc.net/cpanel/apis/cpanel-uapi.md) · [All operations](https://skmtc.net/cpanel/apis/cpanel-uapi/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cpanel/cpanel-uapi/revisions/632e2f8e6d04/schema)
