v1

latestOpenAPI 3.0.2cPanel License2026-08-06657427.1 MB
Mysql
Database Management

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.

get/Mysql/setup_db_and_user

Query parameters

prefixstring
Example:wp

An optional string to prepend to the randomly generated database name. This is in addition to the cPanel user which will appear prior to this. The prefix should be 6 characters or less and be only alphanumeric characters. WARNING: longer prexies lead to less entropy in the random username. Keep it short if you can!

Response

HTTP Request was successful.

apiversioninteger

The version of the API.

funcstring

The name of the method called.

modulestring

The name of the module called.

Example response

{
  "apiversion": 3,
  "func": "setup_db_and_user",
  "module": "Mysql",
  "result": {
    "data": {
      "database": "cpuser_wp_gwl7vpix28owo855yjomc7rsghkbjv0d0kf45kcvzip9tyxw9kdd",
      "database_user": "cpuser_wp_dji1jdt7nhjiwjcjju45",
      "database_user_password": ";1t/U:wnFkCRL9q68]/+<TX=.C#7]n",
      "hostname": "localhost",
      "port": "3306"
    },
    "status": 1
  }
}