Play scala - oauth2 provider mysql issue - mysql

AIM:
I am trying to implement the oauth2 in my application using Play framework 2.3, scala language and MySQL.
WHAT I DID:
I tried to use the scala-oauth2-provider. The given sample is working fine with PostgreSQL. But I want to implement this with MySQL.
WHAT I TRIED:
I have added the below dependencies in the build.sbt
"mysql" % "mysql-connector-java" % "5.1.18",
jdbc
and I removed the below dependency in the given sample.
"org.postgresql" % "postgresql" % "9.3-1100-jdbc41"
Changed the DB configuration in the application.conf
#db.default.url="jdbc:mysql://localhost/oauth"
db.default.url="jdbc:mysql://localhost:3306/oauth"
db.default.driver="com.mysql.jdbc.Driver"
db.default.user="root"
db.default.pass="root"
db.default.host="localhost"
ISSUE:
I am facing the below issue.
[error] - c.j.b.h.AbstractConnectionHook - 14:16:25.117 - Caller+0 at com.jolbox.bonecp.hooks.AbstractConnectionHook.onAcquireFail(AbstractConnectionHook.java:77)
- Failed to obtain initial connection Sleeping for 0ms and trying again. Attempts left: 0. Exception: null.Message:Access denied for user 'root'#'localhost' (using password: YES)
[error] - application - 14:16:25.131 - Caller+0 at play.api.LoggerLike$class.error(Logger.scala:141)
-
! #6nmjm0p14 - Internal server error, for (GET) [/] ->
play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [default]]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94) ~[play_2.11-2.3.4.jar:2.3.4]
at play.api.Configuration.reportError(Configuration.scala:743) ~[play_2.11-2.3.4.jar:2.3.4]
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:247) ~[play-jdbc_2.11-2.3.4.jar:2.3.4]
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:238) ~[play-jdbc_2.11-2.3.4.jar:2.3.4]
at scala.collection.immutable.List.map(List.scala:273) ~[scala-library-2.11.6.jar:na]
Caused by: java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) ~[mysql-connector-java-5.1.18.jar:na]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609) ~[mysql-connector-java-5.1.18.jar:na]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541) ~[mysql-connector-java-5.1.18.jar:na]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:943) ~[mysql-connector-java-5.1.18.jar:na]
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4113) ~[mysql-connector-java-5.1.18.jar:na]
I have given the correct mysql credential only and also I have the database named oauth. Even though it throws "Access denied for user 'root'#'localhost' (using password: YES)" error.
Can anyone help me to fix this?

Please take the following actions:
In mysql, under root user:
CREATE USER 'test1'#'localhost' IDENTIFIED BY 'mypass';
CREATE DATABASE oauth;
GRANT ALL ON oauth.* TO 'test1'#'localhost';
Change credentials in your conf/application.conf:
db.default.user="test1"
db.default.pass="mypass"
Then run your application. This should work.

You have
Access denied for user 'root'#'localhost' (using password: YES)
check your credentials

Related

Problems connecting to a MariaDB server: java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)

I am trying to connect a Spring Boot Application to my MariaDB server which is up and running. I am getting the following error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource
...
Caused by: liquibase.exception.DatabaseException: java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)
Now I've seen that similar questions have been asked on Stackoverflow before, and I tried the most common approaches, like granting all privileges:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED BY '%password%' WITH GRANT OPTION;
And removing the password for the root user:
SET PASSWORD FOR root#localhost=PASSWORD('');
None of these approaches worked so far. I cannot really change the .properties file, but from what I can see a password is generated, encrypted and stored every time the application runs:
connection.driver_class = com.mysql.jdbc.Driver
connection.url = jdbc:mysql://127.0.0.1:3306/local02?useSSL=true
connection.username = root
connection.password = ../../config/local/dbkey.txt
connection.pool_size = 200
It's important to highlight that I am experiencing this problem just on MacOS, on Windows (same files, same DB, same IDE) doesn't arise.
Is there anything else I can try?
As far as I know Spring does not allow to use the root user of mariaDB. You must create a new user and grant priviledges.

Access denied for user 'user_name#'localhost' (using password: NO) in spring

I am trying to create a java spring application with mysql conenction and I am receiving this error :
Access denied for user 'aurelian'#'localhost' (using password: NO)
Mind you that I have user/password and in my application properties, I have my server on, and the password it is correct:
`######## Database Properties #######
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/spring_reddit_clone
spring.datasource.username=aurelian
spring.datasourxce.password=XXXXXXXXXXXXXX
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
spring.datasource.initialize=true
spring.jpa.show-sql=true**strong text**`
Also I am using mysql-connector-java-8.0.25.jar so I do not have any ideeas.
Best Regards,
Aurelian
Typo alert.
Change datasourxce to datasource
spring.datasource.password=XXXXXXXXXXXXXX

Monitoring : Centreon - How to connect centreon user to database?

I'm running Centreon Entreprise Server (CES) 3.3 and added NagVis (1.8.x). They are on a virtual machine (Virtualbox).
When I suceeded in giving the rights to NagVis to reach my Centreon data, Centreon started displaying : "Database error: Could not connect to database", though the centreon user has all privileges on "centreon" and "centreon_storage".
Here's my central-broker-master.log :
[1467987167] error: storage: rebuilder: could not connect to Centreon Storage database: could not open database: Access denied for user 'centreon'#'localhost' (using password: YES) QMYSQL: Unable to connect
[1467988484] error: TCP: error while sending data to peer 'localhost:5670': The remote host closed the connection
[1467988492] config: module applier: loading directory '/usr/share/centreon/lib/centreon-broker'
[1467988492] config: correlation: invalid correlation configuration, correlation engine is NOT loaded
[1467988492] config: applier: 14 modules loaded
[1467988492] error: could not open database: Access denied for user 'centreon'#'localhost' (using password: YES) QMYSQL: Unable to connect
[1467988492] error: TCP: could not connect to localhost:5670: Connection refused
[1467988492] error: could not open database: Access denied for user 'centreon'#'localhost' (using password: YES) QMYSQL: Unable to connect
(the last error is written hundreds of times ...)
And I couldn't find other errors in different logs. (Or wasn't able to find the right logs ...)
The 'centreon' user has the rights on the databases with the IP address of my server as well as with my coputer's address. (This could have been a matter of rights from a distant location)
I don't know any other way to grant my 'centreon' user with extra rights on the database -- Is it even a valid idea to grant my user with all privileges ?
Thanks
EDIT : I tried to solve the problem by using this post : MySQL ERROR 1045 (28000): Access denied for user 'bill'#'localhost' (using password: YES) (I actually had a ''#'localhost' user), but my access to Centreon web is still denied.

Entity Framework & Reverse Engineer Code First & MySQL: error access denied

I'm trying to use Entity Framework Reverse Engineer Code First with MySQL DB, I have installed these: mysql-for-visualstudio-1.2.3 & mysql-connector-net-6.9.3
The connection to MySQL DB seems to work:
I get the following error:
System.Data.ProviderIncompatibleException: The provider did not return
a ProviderManifestToken string. --->
MySql.Data.MySqlClient.MySqlException: Authentication to host
'localhost' for user 'root' using method 'mysql_native_password'
failed with message: Access denied for user 'root'#'localhost' (using
password: NO) ---> MySql.Data.MySqlClient.MySqlException: Access
denied for user 'root'#'localhost' (using password: NO)
I tried a lot of solutions found on the internet but nothing works.
Here is the connection string I have in the web.config:
<add name="TFEContext" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;
port=3306;database=tfe_schema;uid=root;password=********"/>
After 2 days of search, I checked the box "Save my password" and it's working but the password to access the MySQL server is hardcoded in the web.config.

BIRT 4.3.2 on Tomcat 7.0.53 on windows 8.1 64 bit gives error 'Cannot open the connection for the driver: org.eclipse.birt.report.data.oda.jdbc. '

I have been working on creating report using BIRT with MySql. While I am able to run the report successfully using BIRT viewer, when I try to integrate with tomcat, it gives the below error
org.eclipse.birt.report.engine.api.EngineException: An exception
occurred during processing. Please see the following message for
details: Cannot open the connection for the driver:
org.eclipse.birt.report.data.oda.jdbc.
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Failed to get
connection. SQL error #1:Access denied for user 'root'#'localhost'
(using password: NO) ; java.sql.SQLException: Access denied for user
'root'#'localhost' (using password: NO)
Can anyone please help?
the error message indicates that you do not have permissions to loging to MySQL database using root without any password. As far as I remember, default password for root is 'sa' in MySQL. Please check whether you need any password for your database.