Failed to connect to specified database while setting up server

As information, I did not use the user dba again because I thought my problem was using root and I created another user (dba). Then I saw this was not the problem and I used root to set up the server.

What I have been learning and missed up with during setting up the server:

Root must have a password and it should respect some conditions like having a minimum of 8 characters and so on.

The server id is the server name we give while setting up the server but not the server_id we set in the my.ini file while setting up Mysql.

1 Like

That is it
cheers @pcp

Thank you so much @reagan ! OpenMRS has such an amazing community !

2 Likes

ohh @pierre thanks did you solve the problem that you pinned

1 Like

Yes I did @sharif, thank you for checking ! Now I am working on a module to read the OBS for the current month as a way to learn how to deal with the data model. If you have any documentation or article about CRUD (Create, Read, Update and Delete) data for OpenMRS please share.

I have already consulted the devmanual and I think I still need more documentation.

Thanks

@pcp u may like to understand this Abit
 https://wiki.openmrs.org/display/docs/API Try to follow it


2 Likes

Thank you @reagan, I am checking it.

2 Likes

Hi Thanks for the similar question @reagan

I am trying to set the server but I am not able to create one. I have installed MySQL 5.7 and have the MySQL Workbench working. I have set the password for the root user while installing MySQL and also created a user “kavinraju” with a password. But when I try to create a server I am getting the following error.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 47.158 s
[INFO] Finished at: 2020-03-21T20:11:02+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:3.13.4:setup (default-cli) on project standalone-pom: Failed to setup server: Failed to connect to the specified database jdbc:mysql://localhost:3306/server1?autoReconnect=true&sessionVariables=default_storage_engine%3DInnoDB&useUnicode=true&characterEncoding=UTF-8 → [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:3.13.4:setup (default-cli) on project standalone-pom: Failed to setup server

Caused by: java.lang.IllegalStateException: Failed to connect to the specified database jdbc:mysql://localhost:3306/server1?autoReconnect=true&sessionVariables=default_storage_engine%3DInnoDB&useUnicode=true&characterEncoding=UTF-8

Here is the full log cannot-set-up-openMRS-server - Pastebin.com. I have used mvn openmrs-sdk:setup -X to get the DEBUG Log.

Could anyone please help me out with this issue?

Is the new user the one you have provided on the command line prompt? Do they have create database privileges?

1 Like

New user was the one created when I installed MySQL. Yeah it has all the privileges checked. It’s showing the same error for both root & new user I created.

@kavinraju same error i have got that while i am set up openMRS can u check once u have install tomcat correctly or not

@kavinraju , I went for the docker option and it worked fine for me.

@dkayiwa I am also facing the same issue here, supplying the default database URI also does not work. The Docker option works as intended. Any idea why this happens?

Would greatly help if you shared the log.

Hi @kavinraju @sanjula @aman

I can see you are trying to connect to server1 database. Have u already created that before the setup ? It should be created prior setting up openmrs so the installation will be connecting to that database.

The log can be access here: https://pastebin.com/DANp3WCM

I am trying to connect to “openmrs” database, which is already created in mysql, but I get the same error. Tried both in Distribution and Platform setup modes.

Could you use pastebin.com to share the errors
they are easier to read

Sorry my bad, thanks for the suggestion. I have updated the post with the pastebin link accordingly

Hi @sanjula

This might help you some times try to set a password for the root user and try out Again

(https://stackoverflow.com/questions/25777943/failed-to-connect-to-mysql-at-127-0-0-13306-with-user-root-access-denied-for-us/55243053#)

I had the same problem. I’ve installed fresh mysql at Ubuntu but I left mysql password empty, and as a result I couldn’t connect to mysql in any way. Lately I’ve revealed that there is a table of users where are names, hosts, passwords and some plugins. So for my user root@localhost mysql while installing assigned a plugin called auth_socket , which let Unix user “root” log in as a mysql user “root” without password, but don’t allow login as another Unix user. So to fix that you should turn off this plugin and set usual authentication:

  1. open Linux terminal
  2. enter " sudo mysql " you will see “mysql >” which means you’ve connected to mysql as a ‘root’ Unix user and you can type SQL queries.
  3. enter SQL query to change a way how you will log in: ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘your_new_password’; where ‘mysql_native_password’ means - to turn off auth_socket plugin.