MySQL multiple databases

I want to test a PHP application that uses 2 databases. By following https://docs.gitlab.com/ce/ci/examples/php.html I’ve got the most part working.

In the yml file it is possible to specify the MySQL service with a database: https://docs.gitlab.com/ce/ci/services/mysql.html

How can I add a second database?

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.

This doesn’t really answer the question. I am trying to achieve the same thing with postgresql :

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.

1 Like

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.

1 Like