Search code examples
phpdatabasecpanelwhm

Create database programatically from PHP on WHM/cPanel server


I was wondering whether it is possible to create a new database and user, from PHP, on an WHM/cPanel server.


Solution

  • Ok, this is the thing.

    'mysql_create_db' function does not work properly on cPanel servers.

    There is a solution to this though, by using the proprietary cPanel function like so

    http://USER:PASS@HOST:2082/frontend/SKIN/sql/adddb.html?db=DB

    There is also a ready-made script that can be used here http://www.zubrag.com/scripts/cpanel-database-creator.php