Steps to find out about cpanel User for particular user using MySQL query


Staff member
We have to find database name and user name from table name which only we have. Let’s see how to find the details of database and cpanel user.

If you want to determine the user of particular table then first you have to find out database name.

For this you have to run below command, but make sure you have root access.

select table_schema as database_name, table_name from information_schema.tables where table_type = 'BASE TABLE' and table_name = '$TABLE_NAME' order by table_schema, table_name;

Here you have to replace $TABLE_NAME with your table name. With above command we will get below output:

| database_name | table_name |
| host_stud-database | table1 |
1 row in set (0.01 sec)
Now we have database name which is host_stud-database, now we have to find out cpanel user or account owner,this will occur with API, you have to use below command:

whmapi1 list_databases | grep -i $DATABASE_NAME -B 2
Here $DATABASE_NAME is database name. We will get below output:

whmapi1 list_databases | grep -i cptest_test-database -B 2
cpuser: host
engine: mysql
name: host_stud-database