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

 

Description

This function creates 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_mysqluser = $cpanel->api1('Mysql','adduser', array('user','12345luggage') ); // 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_mysqluser = $cpliveapi->api1('Mysql','adduser', ['user','12345luggage'] ); # 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::adduser($FORM('username','password'))">
 Command Line
cpapi1 --user=username Mysql adduser user 12345luggage


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. 

 Output (none)
This function does not return output.

Parameters

ParameterTypeDescriptionPossible valuesExample
usernamestring

Required

The MySQL user's name.

  • If database prefixing is enabled, this will be the cPanel account name, an underscore, and the username
  • If database prefixing is disabled, this will be only the username.

    Important:

    To learn more about database username limits, click the desired 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 up to 13 characters long.
    • A MySQL database with the example_ prefix allows usernames up to eight characters long.
     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 up to 44 characters long.
    • A MariaDB database with the example_ prefix allows usernames up to 39 characters long.

 

user
passwordstring

Required

The MySQL user's password.

A secure password.12345luggage

Returns

This function does not return output.