Description

This function lists an account's MySQL® database users.

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=listusers



$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// List database users.
$list_users = $cpanel->api2(
    'MysqlFE', 'listusers'
);

 



my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# List database users.
my $list_users = $cpliveapi->api2(
    'MysqlFE', 'listusers',
);

 




cpapi2 --user=username MysqlFE listusers



{
  "cpanelresult": {
    "apiversion": 2,
    "data": [
      {
        "dblist": [
           
        ],
        "shortuser": "cpses_ex24NqG8AX",
        "user": "cpses_ex24NqG8AX"
      },
      {
        "dblist": [
           
        ],
        "shortuser": "cpses_exbO3uMNZD",
        "user": "cpses_exbO3uMNZD"
      },
      {
        "dblist": [
           
        ],
        "shortuser": "bobby",
        "user": "example_bobby"
      },
      {
        "dblist": [
          {
            "db": "example_fred",
            "user": "example_fred"
          }
        ],
        "shortuser": "fred",
        "user": "example_fred"
      },
      {
        "dblist": [
          {
            "db": "example_test",
            "user": "example_username"
          }
        ],
        "shortuser": "username",
        "user": "example_username"
      }
    ],
    "func": "listusers",
    "event": {
      "result": 1
    },
    "module": "MysqlFE"
  }
}



Parameters

This function does not accept parameters.

Returns

Return TypeDescriptionPossible valuesExample
dblisthashA hash of databases and their authorized users.A hash that contains the db and user returns. 

db

string

The database name.

The function returns this value in the dblist hash.

A valid database name.
example_database

user

string

The database username.

The function returns this value in the dblist hash.

A valid database username.example_user1
shortuserstringThe short version of the database username.A valid database username, without any database prefix.user1
userstringThe database username.A valid database username.example_user1
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