Monday, February 25, 2013

Error with starting OpenMRS - "Unable to get a connection to the database"

This blog post will be about a very primary error on starting and running OpenMRS medical record system, in which i did my gsoc project and where i am still contributing whenever i get a time (yes i still love openmrs!). This is more like a note to myself.

I recently started to use a new laptop, therefore i moved all my openmrs repositories, .m2 repository and .OpenMRS directories into the new machine, as my intention was saving the time that will be taken to build everything from scratch again. However when i tried to run OpenMRS in the new machine, after installing and setting up mysql server, it returned the following error.

java.lang.RuntimeException: Error occurred while trying to get the updates needed for the database.
Unable to get a connection to the database.  Please check your openmrs 
runtime properties file and make sure you have the correct 
connection.username and
connection.password set ...
.................................................................................
.................................................................................
Caused by: java.sql.SQLException: Access denied for user 'openmrs_user'@'localhost' (using password: YES)


 Although i have worked with the project over an year now, i was also first confused on why the webapp can not be started. But then i realized the fix.

This is simply because when we start the web app from a previous implementation it still uses some of the configuration from its past installation. 
If you go to "webapp" folder in the 'openmrs_home' repository, there is a file called "openmrs-runtime.properties" where there is previous configuration data (usernames, passwords etc.) still present. Now simply delete this file from /home/USER_NAME/.OpenMRS folder if it is present there. Then delete this file from the 'webapp' folder and start again using 'mvn jetty:run'. No more errors, You are good to go now  :) :)


3 comments:

  1. Hello What is the default username and password when logging on to openmrs. I am able to install but can;t figure out what the login credential are. I checked the openmrs.log but it is giving me some incrypted password
    I am using Ubuntu 12.04 LTS

    ReplyDelete
  2. Hi,
    The default username is admin and the password is Admin123. If you install correctly you should be able to log in as super user using these credentials.

    ReplyDelete
  3. Hi I had this same error. I had to delete the folder. / OpenMRS. Just deleting the file OpenMRS-runtime.properties didn't work.

    execute the next line in your command line;

    rm -rf /home/USER_NAME/.OpenMRS

    Note that "USER_NAME" is your USER_NAME!!

    ReplyDelete