Child pages
  • WHM API 1 Functions - list_mysql_databases_and_users
Skip to end of metadata
Go to start of metadata

Description

This function retrieves the MySQL® database and user data for the specified account.

Important:

In cPanel & WHM version 76 and later, when you disable the MySQL role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/list_mysql_databases_and_users?api.version=1&user=user1
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/list_mysql_databases_and_users?api.version=1&user=user1
 Command Line
whmapi1 list_mysql_databases_and_users user=user1


Notes:

  • You must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{  
   "data":{  
      "mysql_databases":{  
         "user1_database1":[  
            "user1_user5"
         ]
      },
      "mysql_config":{  
         "use_db_prefix":"1",
         "prefix_length":8,
         "mysql-version":"5.5"
      }
   },
   "metadata":{  
      "reason":"OK",
      "version":1,
      "command":"list_mysql_databases_and_users",
      "result":1
   }
}
 Output (XML)
<result>
    <metadata>
        <reason>OK</reason>
        <version>1</version>
        <result>1</result>
        <command>list_mysql_databases_and_users</command>
    </metadata>
    <data>
        <mysql_config>
            <use_db_prefix>1</use_db_prefix>
            <mysql-version>5.5</mysql-version>
            <prefix_length>8</prefix_length>
        </mysql_config>
        <mysql_databases>
            <user1_database1>user1_user5</user1_database1>
        </mysql_databases>
    </data>
</result>


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
userstring

Required

The username for a specified account.

A valid string.user1

Returns

Return

TypeDescriptionPossible valuesExample

mysql_config

hash

A hash of the user's MySQL database configuration settings.

This hash includes the user_db_prefix, mysql-version, and prefix_length returns.

 

use_db_prefix

Boolean

Whether database prefixing is enabled on the server.

The function returns this value in the mysql_config hash.

  • 1 — Enabled.
  • 0 — Disabled.
1

mysql-version

integer

The MySQL version installed on the server.

The function returns this value in the mysql_config hash.

A positive integer.

5.5

prefix_length

integer

The maximum number of characters allowed for the prefix on this server.

The function returns this value in the mysql_config hash.

8 or 16, dependent upon the installed version of MySQL.8

mysql_databases

hash

A hash of database names and users.

This hash includes the database_user return. 

database_user

array

A list of database users.

The function returns this value in the mysql_databases hash.

Note:

The return's name is the MySQL database's name.

A comma-separated list of database users.
user1_user5