Connect OpenMRS to an external database

I have installed Bahmni on a single server on AWS, it’s a Centos 6.9, everything works fine. But I would like to know if there is a (correct) way to use an external database for the services (specifically for OpenMRS) instead to use the installed on the same server so we can have better administration of the data. I found a file on the OpenMRS repo where it is the connection Would it be enough to change that info in order to connect to an external database e.g. RDS instance? Will this affect the other systems e.g. OpenERP, OpenElis, etc.?

cc. @sommardahl @cristian @ronald721hn

1 Like

@eliyas do you mean you have another openmrs database already and you want to connect to that? Or you just mean the ability to have database installed on a different machine. If latter is the case, then it’s simple. Bahmni allows that. In the inventory file you will have specify different IPs/hostname for, say, bahmni-emr on x and bahmni-emr-db on y, and the installer will install emr software at x and emr db at y.


@mddubey Thanks for your response.

I’ll say it’s the second case, but we already have Bahmni installed and we have already some data added for concepts, translations and UI. So I don’t think we would like to run the installer again because we will lose what we have right now.

Is there any possibility to only change the connection somewhere in the code and then create a dump from our current database in the same server as the apps and import it on the external database?


Hi @eliyas,

You can try changing the connection.url key value in /opt/openmrs/etc/ file. Make sure you can access the remote database from your local server before trying this. Hope this helps.

Bindu’s suggestion will work, but you will need to do that all other components as well (OpenMRS, Bahmni Reports, OpenELIS, OpenERP, Dcm4Che etc). You can always modify the connection strings in each of the components for database components.

Alternatively, You should be able to reinstall the databases during installation. You need to create backups of the databases. and in the setup.xml, you can setup the databases to be restrored during the install process.

@eliyas Rerunning the installer will not delete the database. You can take a backup and try re-running the installer with IP changed in the inventory file for appropriate roles (may be bahmni-emr-db in your case). You can restore your dump on that machine once you have mysql installed.

@eliyas What route did you follow to achieve RDS setup?

Am trying to achieve the same and failing terribly at it.

Attempted to add the RDS hostname as a host in the inventory file but received a SSH connection issue to it that I have no idea off.

Attempted the other route of setting it manually on the properties file and my instance crashed with connection refused, the logs do not seem to point me to the root cause of this issue.

Please revert if you figured away around it. Thanks

Sir I have the first case. I have an external data base named “openmrs.sql” and i want to use it in OpenMRS through Bahmni. How can I do that. Please help me with detailed steps, I installed Bahmni yesterday on windows 10 on vagrant box. Thanks and Regards.

Hello @anujpathak1996,

Please refer the advance steps for installing bahmni, where in the step 3 it is mentioned, how to use existing dump while installing bahmni.

However, This is the recommended approach when you have a dump of an existing bahmni installation. In case you have an OpenMRS RefApp dump(or any other type of dump) you might find inconsistencies since it might not have been tested for that scenario. I am not sure if there is guide for migrating from OpenMRS to Bahmni. There are open talks though. (Is it possible to migrate from OpenMRS to Bahmni?)

I would advice you to join the Bahmni Slack channel where you would be able to get quick response for your questions.

CC: @angshuonline @buvaneswariarun @binduak

1 Like

Okay , Thank you.