Connecting To MYSQL Databases With Web Host Manager and Cpanel Accounts


Using Databases With Web Host Manager and Cpanel

By now, you may know that Web Host Manager is quite a fine tool to administrate accounts and your Linux Hosting account. Having the ability to create new accounts with new cpanels allows for all sorts of web management.

Although you may want to keep all database usage and files within specific accounts, you are not required to do so. You do have the option to use databases from different accounts. For example, if you have one account called mainaccount and another account called mysecondaccount, you could connect to databases from mainaccount. The simple trick is to just use the aaccount prefix which appends to all database usernames and databases.

The examples below show how you can connect to a database from another account. You simply add the specific connection variables into your file(s).

Database Connection to mainaccount:
    $host = "localhost";  
    $user = "mainaccount_name";
    $pw = "add_password_here";
    $database = "mainaccount_databasename";

Database Connection to mysecondaccount:
    $host = "localhost";  
    $user = "mysecondaccount_name";
    $pw = "add_password_here";
    $database = "mysecondaccount_databasename";