Description
This function renames a MySQL® database.
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.
- The system creates a new database.
- The system moves data from the old database to the new database.
- The system recreates grants and stored code in the new database.
- The system deletes the old database and its grants.
Warning:
- 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 function's error message will include the additional failures.
- In rare cases, the system creates the new database successfully, but fails to complete step 4. The system treats this as a success, but the function will return warning messages that describe the failure.
Examples
Note:
Use cPanel's API Shell interface (Home >> Advanced >> API Shell) to directly test cPanel API calls.
Parameters
Parameter |
Type |
Description |
Possible values |
Example |
oldname |
string |
Required The database's current name. |
A database on the cPanel account. |
mydb |
newname |
string |
Required The database's new name. |
A valid database name. Important:
|
newlyrenamed |
Returns
This function only returns metadata.