Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 921535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:53:14+00:00 2026-05-15T18:53:14+00:00

Is there a sort of reliable way to programmatically create MySQL databases and MySQL

  • 0

Is there a sort of reliable way to programmatically create MySQL databases and MySQL users on shared Linux hosting plans from a PHP page? For instance, accessing cpanel or phpmyadmin through an API or hook if I know my cpanel access information and/or my FTP information?

Occasionally I see this with some sites and products but don’t know how they do it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:53:15+00:00Added an answer on May 15, 2026 at 6:53 pm

    Thanks to @Alex C who got me on the right track. The following will work with many shared hosting plans, but you’ll want to check with their policies on this first. Mine wrote me back in a tech support ticket and said, “You have to automate through a cpanel script.” So, that’s what this is.

    In the example below, I would have already purchased root.com as my main root domain of my shared hosting plan. I would be wanting to setup a database named “user_myexample” with password “myexample” assigned with full privileges to user “user_myexamp”. If the “user_” prefix and “myexamp” looks odd — it’s because cpanel has a prefix based on the root user’s user account into cpanel, and the database user name can only be 7 characters maximum.

    To connect to Cpanel to make this happen, I entered a cpanel homepage URL (which varies with hosting plan) so that it could be parsed and reused. Also, I provided my root.com’s cpanel user/pass information.

    The echo statements are just the output response whether each HTTP GET request worked or not. You may want to inspect that to see if there’s something you can parse out of that output for success/failure.

    Note some hosting plans block file_get_contents connecting to a URL, so you may have to switch with fopen($sURL, ‘r’) or Curl API.

    <?php
    
    // @ input vars
    $sPastedCpanelHomepageURL = 'https://root.com:2083/frontend/x3/index.html';
    $sNewDB = 'myexample';
    $sNewDBUser = 'myexamp'; // must be 7 chars max
    $sNewDBPass = 'myexample';
    $sCPanelUser = 'user';
    $sCPanelPass = 'pass';
    
    // @ processing
    $sCP = dirname($sPastedCpanelHomepageURL);
    $sCP = str_replace('://','://' . $sCPanelUser . ':' . $sCPanelPass . '@',$sCP);
    
    $sPrefix = substr($sCPanelUser, 0, 7) . '_';
    
    $sTask1 = '/sql/addb.html?';
    $sTask2 = '/sql/adduser.html?';
    $sTask3 = '/sql/addusertodb.html?';
    
    $sNewDB = urlencode($sNewDB);
    $sNewDBUser = urlencode($sNewDBUser);
    $sNewDBPass = urlencode($sNewDBPass);
    $sCPanelUser = urlencode($sCPanelUser);
    $sCPanelPass = urlencode($sCPanelPass);
    
    $sNewDBUser = substr($sNewDBUser, 0, 7);
    
    $asData1 = array(
      'db' => $sNewDB
    );
    $sData1 = http_build_query($asData1);
    $s = file_get_contents($sCP . $sTask1 . $sData1);
    echo "$s\n";
    
    $asData2 = array(
      'user' => $sPrefix . $sNewDBUser,
      'pass' => $sNewDBPass,
      'pass2' => $sNewDBPass
    );
    $sData2 = http_build_query($asData2);
    $s = file_get_contents($sCP . $sTask2 . $sData2);
    echo "$s\n";
    
    $asData3 = array(
      'user' => $sPrefix . $sNewDBUser,
      'db' => $sPrefix . $sNewDB,
      'update' => '',
      'ALL' => 'ALL'
    );
    $sData3 = http_build_query($asData3);
    $s = file_get_contents($sCP . $sTask3 . $sData3);
    echo "$s\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any sort of free control which does what the Occupation field does
Is there some sort of formatting protocol for html email? We have an automated
Is there some sort of profiling tool available? View source and search/replace?
Is there some sort of built-in authentication in WCF? I need to expose a
Is there any sort of plug-in or tool available for Visual Studio 2008 to
is there any sort of XY-Layout to Java? So I can set a Button
Is is there some sort of library that would allow me to convert a
I understand the following elements : there is some sort of crawling (configured in
There have been a couple of questions that sort of dealt with this but
Is there anyway to have a sort of virtual static member in C++? For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.