Description

This function creates a MySQL® database.

Examples


$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
$add_db = $cpanel->api1('Mysql','adddb', array('database') ); // Call the function.

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
my $add_db = $cpliveapi->api1('Mysql','adddb', ['database'] ); # Call the function.

<cpanel Module="Mysql::adddb( $FORM('dbname'))">
cpapi1 --user=username Mysql adddb database

This function does not return output.

Parameters

ParameterTypeDescriptionPossible valuesExample
dbnamestring

Required

The MySQL database name.

A valid database name.

If database prefixing is enabled and this parameter does not begin with the prefix, the function will automatically add it.

The maximum length of the database name is 64 characters. However, due to the method that cPanel & WHM uses to store MySQL database names, each underscore character requires two characters of that limit. Therefore, if you enable database prefixing, the maximum length of the database name is 63 characters, which includes both the database prefix and the underscore character. Each additional underscore requires another two characters of that limit.

If the total length of the username is longer than the character limit for database usernames, the function will fail.

database

Returns

This function does not return output.