Description

This function creates a database user.


We strongly recommend that you use the following UAPI function instead of this function:

Examples 




https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=MysqlFE&cpanel_jsonapi_func=createdbuser&dbuser=example_user1&password=12345luggage



$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Creates the database user "example_user1"
$create_user = $cpanel->api2(
    'MysqlFE', 'createdbuser', 
    array(
        'dbuser'   => 'example_user1',
        'password' => '12345luggage',
 ) 
);

 



my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Creates the database user "example_user1"
my $create_user = $cpliveapi->api2(
    'MysqlFE', 'createdbuser',
    { 
        'dbuser'   => 'example_user1',
        'password' => '12345luggage',
    }
);

 




cpapi2 --user=username MysqlFE createdbuser dbuser=example_user1 password=12345luggage



 {
  "cpanelresult": {
    "apiversion": 2,
    "data": [
      1
    ],
    "func": "createdbuser",
    "event": {
      "result": 1
    },
    "module": "MysqlFE"
  }
}



Parameters

ParameterTypeDescriptionPossible valuesExample
dbuserstring

Required

The database username.

  • You cannot create a database username that already exists.
  • Whether database prefixing is enabled limits the maximum number of available database characters. You can enable or disable database prefixing via the database_prefix key in The cpanel.config File.


A valid username.

example_user1
passwordstring

Required

The new password.

A valid password.12345luggage

Returns

ReturnTypeDescriptionPossible valuesExample
reasonstring

A reason for failure.

This function only returns a reason value if it failed.


A string that describes the error.

This is an error message.
resultBoolean

Whether the function succeeded.

  • 1 — The function succeeded.
  • 0 — The function failed.
1