My project has its own database. Also, I use table of users, which is on other database. Two offices have their data on the same server, but third one has its own user table
Federated tables are your solution for tables on other servers. They are very slow though if you perform joins on them. If you just want to read data from another database on the same server you can use a view. This way you have all tables virtually in one database and you have to open only one connection in your application.
CREATE
VIEW `my_db`.`table_name`
AS
(SELECT * FROM `other_db`.`table_name`);