Description

This function lists MySQL® database users.

 It can list all users, or only users who can access a specific database.

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=getdbusers&db=example_database



$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// List database users with permissions to "example_database"
$permissions_database = $cpanel->api2(
    'MysqlFE', 'getdbusers', 
    array(
        'db' => 'example_database',
 ) 
);

 



my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# List database users with permissions to "example_database"
my $permissions_database = $cpliveapi->api2(
    'MysqlFE', 'getdbusers',
    { 
        'db' => 'example_database',
    }
);

 




cpapi2 --user=username MysqlFE getdbusers db=example_database



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



Parameters

ParameterTypeDescriptionPossible valuesExample
dbstring

The database name.

If you do not specify a value, the function returns a list of all database users on the account.

A valid string.

example_database

Returns

ReturnTypeDescriptionPossible valuesExample
 array

A list of authorized database users.

One or more valid database usernames.
example_username
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