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.

SecurityBasicAuth
Request
query Parameters
prefix
string

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!

Example: prefix=wp
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/setup_db_and_user
Request samples
uapi --output=jsonpretty \
  --user=username \
  Mysql \
  setup_db_and_user \
  prefix='wp'
Response samples
application/json
{
  • "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
      },
    • "errors": null,
    • "messages": null,
    • "metadata": { },
    • "status": 1,
    • "warnings": null
    }
}