phpMyAdmin as subdomain for DB from the top server

I’m trying to install phpMyAdmin (via scripts) as a subdomain on Virtualmin and be able access a database from the top domain.

I have try to create a sub server but it creates separate DB as well so PAM is not able to reach a DB from the top domain.

phpMyAdmin is just an interface for accessing the database. It will provide you access to what ever database you use the login details for.

So you can have:

Main -
DB - fooDB
DB User - fooDBUsr
Sub -
DB - barDB
DB User - barDBUsr

phpMyAdmin installed to would allow access to either database as long as the correct login is used. If you use the barDBUsr login you will only see the barDB database, if you use the fooDBUsr login you will see the fooDB database.

If you used the root database login you would see all the databases.