If both databases are in the same MySQL container, it is possible to connect only to one database and send selects to both, like SELECT * FROM database1.table1 AND SELECT * FROM database2.table2. I know it’s not an ideal solution, but may be a workaround.
By the way, can you connect to MySQL from Gitlab-CI and PHP? I’m always getting a Connection refused error, as I posted here.
If you’re using Docker and have Gitlab >= 9.4, you can use service aliases as shown in the new docs section. As @kopax commented in stackoverflow, looks like a corrected bug.
This doesn’t really describe how to fully configure two databases, just how to set two services with two aliases. How do we set each database name, user, and password.