Unable to connect to mysql from sts - mysql

I have provided the credentials in application.properties to connect to Mysql but spring-boot is failing to take those credentials.
This is my application.properties file:
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:mysql://localhost/person_example
spring.datasource.data-username=root
spring.datasource.data-password=password
the error shown in console:
java.sql.SQLException: Access denied for user ''#'localhost' (using password: NO)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.15.jar:8.0.15]

See docs on common speinh properties here:
https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
You need to use spring.datasource.username and spring.datasource.password

Related

phpmyadmin access denied error :invalid settings

i got this error
MySQL said: Documentation
Cannot connect: invalid settings.
mysqli::real_connect(): (HY000/1045): Access denied for user 'pma'#'localhost' (using password: NO)
Connection for controluser as defined in your configuration failed.
mysqli::real_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: NO)
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

Unable to launch Hive metastore with MySql empty password

My local MySql do not have password for login, so I set hive-site.xml config for:
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value/>
<description>password to use against metastore database</description>
But After launching metastore with
hive --service metastore
It always show there's password
Caused by: java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:873) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1710) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2188) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.ConnectionImpl.connectOneTryO
How to fix it?
Sovled by add --hiveconf when start the server.
hive --hiveconf javax.jdo.option.ConnectionPassword= --service metastore

MySQL Access denied for user 'User'#'localhost' (using password: YES)

I connected a MySQL database for a project (java web application) in netbeans. I created MySQL server with correct login details as root and created a database. I connected my database to the project, but when I am running the application it was showing error in the browser as:
type Exception report
message Internal Server Error
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.sql.SQLException: Access denied for user 'User'#'localhost' (using password: YES)
root cause
java.sql.SQLException: Access denied for user 'User'#'localhost' (using password: YES)
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1.1 logs.
Entry in the log file is:
java.sql.SQLException: Access denied for user 'User'#'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:925)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1704)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1250)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2465)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2498)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2283)
at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:822)
at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:404)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:317)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at org.apache.jsp.Login_jsp.cn(Login_jsp.java:114)
at org.apache.jsp.Login_jsp._jspService(Login_jsp.java:589)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
I am tired in few ways as mentioned in some other forms but not use.
You didn't create the user 'bkUser'#'localhost' correctly.
I found solution, When I was using sql statement for grant privileges i used 'user#%' because of that it was not working. Correct sql statement was:
GRANT ALL PRIVILEGES ON dbname.* TO 'User'#'localhost' IDENTIFIED BY 'Pass' WITH GRANT OPTION;

Play scala - oauth2 provider mysql issue

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

JDBC / MYSQL: java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: NO)

With this code
String url = "jdbc:mysql://localhost/mysql";
Connection con = DriverManager.getConnection(url, "root", "");
I get the following exception.
java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: NO)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:943)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4113)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1308)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2336)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2369)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at MyTest1.main(MyTest1.java:29)
I logged into the database using the command tool with root and no password. I was able to telnet to the database and I get this message
N
5.5.17-log
7{*Zj%u☻ǧ|tR}=Vz'L,6imysql_native_password"
Even I also faced the same problem. But, in my application, I did one mistake like I forgot to give password. You can try to manually login to your MySQL and check what is the username and password you are using to log in. That same details you can use in the URL. Better to give database names also. As like below
For MySQL:
String url = "jdbc:mysql://localhost:3306/mysql";
Connection con = DriverManager.getConnection(url, "root", "");
In the above, you forgot to give the port number of MySQL. You can check once your MySQL has a port number or not. By default, MySQL port number is 3306. Better to create and use your own database.
If the above one is not working try for GRANT all privileges to user root on your user database. To grant all privileges below is the query,
GRANT ALL PRIVILEGES ON mysql.* TO 'root'#'localhost' WITH GRANT OPTION;
or else
GRANT ALL PRIVILEGES ON mysql.* TO 'root'#'localhost' IDENTIFIED BY 'root';
'root'#'localhost' is different from 'root'#'%'. It may still be a permissions issue.
I suggest that you log in through the console, create a 'test'#'%' user with a password, and give it all permissions. You can learn how to do that here.
It turned out to be some problem with my MYSQL installation. I uninstalled the AMP package I was using and installed XAMPP instead and it works.