@john123, just noticed you want to use diff db for each qa instance, it is bit complicated if you want to have one instance of q2a just for user access. You can think of wordpress SSO solution if you want to use diff db for each qa site.
If you want to use single db for all qa site then solution in answer we discussed works. hope this helps you.