Our documentation is getting an overhaul! We would like your input! Click here to take a look at the beta launch of our new documentation site! Only cPanel & WHM version 82 documentation exists on our beta at this time. 84 will be added to the new site soon! Leave your feedback here: https://go.cpanel.net/docsfeedback
UAPI Functions - Mysql::list_users - Developer Documentation - cPanel Documentation
Child pages
  • UAPI Functions - Mysql::list_users
Skip to end of metadata
Go to start of metadata

Description

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

Important:

When you disable the MySQL role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Mysql/list_users


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// List database users.
$list_users = $cpanel->uapi(
    'Mysql', 'list_users'
);


Note:

For more information, read our Guide to the LiveAPI System.

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


Note:

For more information, read our Guide to the LiveAPI System.

 Command Line
uapi --user=username Mysql list_users


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{  
   "metadata":{  
      "transformed":1
   },
   "messages":null,
   "errors":null,
   "warnings":null,
   "data":[  
            {
            "user" : "cpuser_user1",
            "shortuser" : "user1",
            "databases" : [
               "cpuser_db1,"
			   "cpuser_db2,"
            ]
         }
   ],
   "status":1
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

This function does not accept parameters.

Returns

Return TypeDescriptionPossible valuesExample
data array of hashesAn array of database information hashes.Each has contains the user and shortuser returns and the databases array.

user

string

The database username.

The function returns this value in the data array of hashes.

A valid database username.example_user1

shortuser

string

The short version of the database username.

The function returns this value in the data array of hashes.

A valid database username without a database prefix.user1

databases

array

An array of databases that belong to the database user.

If no users are assigned to a database, the function returns an empty array.


The function returns this value in the data array of hashes.

An array of databases.user_database1, user_database2