Child pages
  • cPanel API 1 Functions - Mysql::adduserdb
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Description

This function grants permissions to a MySQL® database user.

Warning:

cPanel API 1 is deprecated. Do not use this function. Instead, we strongly recommend that you use the following newer functions:

Examples


 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
$add_perms = $cpanel->api1('Mysql','adduserdb', array('database','username','alter lock create') ); // Call the function.


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.
my $add_perms = $cpliveapi->api1('Mysql','adduserdb', ['database','username','alter lock create'] ); # Call the function.


Note:

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

 cPanel Tag System (deprecated)


Warning:

In cPanel & WHM version 11.30 and later, cPanel tags are deprecated. We provide this example to help developers move from the old cPanel tag system to our LiveAPI system. We strongly recommend that you only use the LiveAPI system to call the cPanel APIs.

<cpanel Module="Mysql::adduserdb( $FORM('dbname','user','perms_list'))">
 Command Line
cpapi1 --user=username Mysql adduserdb database user "alter lock create"


Notes:

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

    /usr/local/cpanel/bin/cpapi1

 Output (HTML)
This function does not return output.

Parameters

ParameterTypeDescriptionPossible valuesExample
dbnamestring

Required

The MySQL database name.

A valid MySQL database.

Important:

To learn more about database username limits, click your database type:

 MySQL

MySQL limits the database username to 16 characters. The system includes the database prefix (the first eight characters of the cPanel account's username and an underscore character) in the character count for the username.

For example:

  • A MySQL database with the db_ prefix allows usernames that contain up to 13 characters.
  • A MySQL database with the example_ prefix allows usernames that contain up to eight characters.
 MariaDB

MariaDB limits the database username to 47 characters. The system includes the database prefix (all of the cPanel account's username and an underscore character) in the character count for the username.

For example:

  • A MariaDB database with the db_ prefix allows usernames that contain up to 44 characters.
  • A MariaDB database with the example_ prefix allows usernames that contain up to 39 characters.

database
usernamestring

Required

The MySQL user's name.

A valid MySQL user.user
perms_liststring

Required

The permissions to grant to the MySQL user.

Use any of the following values in a space-delimited list:
  • alter — ALTER
  • temporary CREATE TEMPORARY TABLES
  • routine CREATE ROUTINE
  • create CREATE
  • delete DELETE
  • drop DROP
  • select SELECT
  • insert INSERT
  • update UPDATE
  • references REFERENCES
  • index INDEX
  • lock LOCK TABLES
  • all ALL
alter lock create

Returns

This function does not return output.

 

 

 

 

 

  • No labels