Description

This function lists a user's privileges on a MySQL® database.


  • This function is currently deprecated and does not function. We strongly recommend that you use the MysqlFE::getdbuserprivileges function.
  • We strongly recommend that you use UAPI instead of cPanel API 2. However, no equivalent UAPI function exists.

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=userdbprivs&db=example_db1&dbuser=example_user1



$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// List privileges for "example_user1" on "example_db1"
$list_privs = $cpanel->api2(
    'MysqlFE', 'userdbprivs', 
    array(
        'db'     => 'example_db1',
        'dbuser' => 'example_user1',
  ) 
);



my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# List privileges for "example_user1" on "example_db1"
my $list_privs = $cpliveapi->api2(
    'MysqlFE', 'userdbprivs',
    { 
        'db'     => 'example_db1',
        'dbuser' => 'example_user1',
 }
);




cpapi2 --user=username MysqlFE userdbprivs db=example_db1 dbuser=example_user1



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



Parameters

ParameterTypeDescriptionPossible valuesExample
dbstring

Required

The database name.

A valid database name.
example_db1
dbuserstring

Required

The database username.

A valid database username
example_user1

Returns

This function's Boolean values only return if the database user has privileges for that database. If the value is 0, the function will not return that value.


ReturnTypeDescriptionPossible valuesExample
ALL PRIVILEGESBooleanWhether the user has all privileges on the database.
  • 1 — The user has all privileges.
1
ALTERBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1

ALTER ROUTINE

BooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
CREATEBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1

CREATE ROUTINE

BooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
CREATE TEMPORARY TABLESBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
CREATE VIEWBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
DELETEBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
DROPBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
EVENTBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
EXECUTEBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
INDEXBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
INSERTBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
LOCK TABLESBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
REFERENCESBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
SELECTBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1

SHOW VIEW

BooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
TRIGGERBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
UPDATEBooleanWhether the user has this privilege on the database.
  • 1 — The user has this privilege.
1
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