Mysql
25 functions, invoked through the cpanel_uapi tool.
cpanel_uapi(service_id, module="Mysql", function, params). Live availability depends on the cPanel features JetHost has enabled on your account — call list_cpanel_operations to see what is active.add_host GET#
Enable remote MySQL host access
This function authorizes a remote MySQL® host to access the account's databases.
Important:
When you disable the MySQL role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.
add_host_note GET#
Add remote MySQL host note
This function adds a note about a remote MySQL® server.
Important:
- If you attempt to add a note to an unauthorized remote MySQL server, the function will fail.
- When you disable the MySQL role, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.
check_database GET#
Validate MySQL database integrity
This function checks for errors in all of the tables in a MySQL® database.
Important:
When you disable the MySQL role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:
create_database GET#
Create MySQL database
This function creates a MySQL® database.
Important:
When you disable the MySQL/MariaDB role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.
create_user GET#
Create MySQL user
This function creates a MySQL® database user.
Important:
When you disable the MySQL role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.
delete_database GET#
Delete MySQL database
This function deletes a MySQL® database.
Important:
when you disable the MySQL/MariaDB role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.
delete_host GET#
Disable remote MySQL host access
This function removes a remote MySQL® host's access to the account's databases.
Important:
When you disable the MySQL role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.
delete_user GET#
Delete MySQL user
This function deletes a MySQL® user.
Important:
When you disable the MySQL role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.
dump_database_schema GET#
Return MySQL database schema
This function returns a string that you can give to MySQL® to recreate a particular database’s schema.
Important:
When you disable the MySQL/MariaDB role and remote MySQL is not configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
The string to give to MySQL.
get_host_notes GET#
Return remote MySQL host notes
This function returns the notes associated with the account's remote MySQL® hosts.
Important:
When you disable the MySQL/MariaDB role and remote MySQL is not already configured, the system disables this function.
No parameters.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
The keys are remote MySQL hostnames or IP addresses and values are their corresponding notes.
get_privileges_on_database GET#
Return MySQL user privileges
This function lists a MySQL® database user's privileges.
Important:
When you disable the MySQL role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:
An array of privileges. Note: If the database user does not have privileges on the database database, this array will return empty. ALL PRIVILEGES One or more of the following individual privileges: ALTER ALTER ROUTINE CREATE CREATE ROUTINE CREATE TEMPORARY TABLES CREATE VIEW DELETE DROP EVENT EXECUTE INDEX INSERT LOCK TABLES REFERENCES SELECT SHOW VIEW TRIGGER UPDATE
get_restrictions GET#
Return MySQL name length restrictions
This function lists a MySQL® database's name, username length restrictions, and database prefix.
Important:
When you disable the MySQL/MariaDB role and remote MySQL is not already configured, the system disables this function.
No parameters.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
get_server_information GET#
Return MySQL server host information and version
This function returns information about the account's MySQL® host.
Important:
When you disable the MySQL role and remote MySQL is not already configured, the system disables this function.
No parameters.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
list_databases GET#
Return MySQL databases
This function lists an account's MySQL® databases.
Important:
When you disable the MySQL/MariaDB role and remote MySQL is not configured, the system disables this function.
No parameters.
Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:
list_routines GET#
Return MySQL user routines
This function returns a database user's MySQL® routines.
Important:
When you disable the MySQL/MariaDB role and remote MySQL is not configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:
An array of MySQL routines. If no routines exist, the function returns an empty array.
list_users GET#
Return MySQL users
This function lists an account's MySQL® database users.
Important:
When you disable the MySQL/MariaDB role and remote MySQL is not configured, the system disables this function.
No parameters.
Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:
locate_server GET#
Return MySQL server host information
This function returns information about the account's MySQL® host.
Important:
When you disable the MySQL/MariaDB role and remote MySQL is not already configured, the system disables this function.
No parameters.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
rename_database GET#
Update MySQL database name
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 and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.
rename_user GET#
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.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.
repair_database GET#
Repair MySQL database tables
This function repairs all of the tables in a MySQL® database.
Important:
When you disable the MySQL/MariaDB role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:
revoke_access_to_database GET#
Remove MySQL user privileges
This function revokes a MySQL® database user's privileges.
Important:
When you disable the MySQL role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.
set_password GET#
Update MySQL user password
This function sets a MySQL® database user's password.
Important:
When you disable the MySQL role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
set_privileges_on_database GET#
Update MySQL user privileges
This function sets a MySQL® database user's privileges.
Important:
When you disable the MySQL/MariaDB role, and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.
setup_db_and_user GET#
Create a randomly named MySQL username/database set.
This function creates a randomly named MySQL® database and user. This allows a 3rdparty tool to create its own DB without needing any knowledge of cPanel internals such as quotas or other limits. These will simply be passed back as an error.
Important:
When you disable the MySQL/MariaDB role and remote MySQL is not already configured, the system disables this function.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
update_privileges GET#
Update MySQL® privileges
This function updates privileges for all MySQL® databases and users on an account.
Important:
When you disable the MySQL/MariaDB role and remote MySQL is not configured, the system disables this function.
No parameters.
Response — normalized as { ok, data, errors[], warnings[] }; data contains:
Payload varies by call.