springboot can't connect with mysql8.0 - mysql

access to localhost database was dennied
java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:829) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:449) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:242) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358) ~[HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477) [HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560) [HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) [HikariCP-3.4.5.jar:na]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) [HikariCP-3.4.5.jar:na]
this is application.yml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: 000000
url: jdbc:mysql://127.0.0.1:3306/student?useUnicode=true&characterEncoding=utf8&serverTimezone=CST
this is mysql user table
enter image description here
I have tried to chang the yml file and database settings but failed,is it the problem about the mysql version?

is it the problem about the mysql version?
No, It's not. You are trying to connect with wrong credentials. Just check your username&password.
Possibly this answer will help you.

Related

Can anyone tell me how to solve these errors? [duplicate]

This question already has an answer here:
Exception in thread "main" java.sql.SQLException: Access denied for user ''#'localhost' (using password: NO)
(1 answer)
Closed 2 years ago.
Exception in thread "main" java.sql.SQLException: Access denied for user ''#'localhost' (using password: NO)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.mysql.cj.jdbc.admin.TimezoneDump.main(TimezoneDump.java:70)
Try adding a password and try connecting again.
GRANT ALL ON <database>.* TO '<user>'#'localhost' IDENTIFIED BY '<password>';

Unable to connect to mysql from sts

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

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

Cannot connect to MySQL Database on Node.js

I still cannot figure out why Im still getting this error message when trying to connect to the MYSQL Server on Node.js -
ERROR -
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'#'localhost' (using password: YES)
at Handshake.Sequence._packetToError (C:\Users\Admin\Desktop\Test Files\Hello World!\node_modules\mysql\lib\protocol\sequences\Sequence.js:52:14)
at Handshake.ErrorPacket (C:\Users\Admin\Desktop\Test Files\Hello World!\node_modules\mysql\lib\protocol\sequences\Handshake.js:103:18)
at Protocol._parsePacket (C:\Users\Admin\Desktop\Test Files\Hello World!\node_modules\mysql\lib\protocol\Protocol.js:279:23)
at Parser.write (C:\Users\Admin\Desktop\Test Files\Hello World!\node_modules\mysql\lib\protocol\Parser.js:76:12)
at Protocol.write (C:\Users\Admin\Desktop\Test Files\Hello World!\node_modules\mysql\lib\protocol\Protocol.js:39:16)
at Socket.<anonymous> (C:\Users\Admin\Desktop\Test Files\Hello World!\node_modules\mysql\lib\Connection.js:103:28)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:266:12)
at readableAddChunk (_stream_readable.js:253:11)
JS -
var mysql = require('mysql');
var con = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '*****',
database: 'mydb'
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
});
There is no prolem in your node.js
node.js require only mysql installation
-> go to installation of nodejs in the command prompt and enter
npm install mysql
in Eclipse:
1) install the nodejs plugin
2) open package.json in the nodejs project and enter
"author": "Krish",
"dependencies": {
"mysql": "2.x.x"
},
3) right click on the project run -> node install
it will install the mysql and you are ready to connect the Database
ER_ACCESS_DENIED_ERROR
1) go to mysql command prompt
mysql> create user 'root'#localhost IDENTIFIED BY 'password';
2) give permission
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' WITH GRANT
OPTION;
or
mysql>SHOW GRANTS FOR 'root'#'localhost';
now you can run you JS . it will be conneced
If you hosting SQL in xampp then the root user in localhost does not have any password, so remove the password.
It worked for me.

Another 1045 : Access denied for user 'someone'#'localhost' (using password: YES)

As lot of dummies, I cannot connect to MySQL server with user.
This is settings of my USER in DB mysql table user
Host: %
User: someone
Password: mypassword
Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, Create_user_priv: Y
max_questions, max_updates, max_connection, max_user_connections: 0
Connection
Im connecting via localhost console OR phpMyAdmin installed on this machine.
MySQL Server
Information from phpMyAdmin: Server: Localhost via UNIX socket | Server version: 5.0.70-log | Protocol version: 10
When mysql server is running as mysqld_safe --skip-grant-tables & then I can connect to server as any user.
When mysql server is running normally as /etc/init.d/mysqld start then I cannot an I have error
1045 : Access denied for user 'someone'#'localhost' (using password: YES)
I was spending hours to find solution in google and mysql documentation but without result. Probably it will be some essential settings. Hope you will give me some suggestion. Thanks a lot.
You probably need to reset the password for the someone user. It happens often.
Try to start your local server with no password check:
mysqld_safe --skip-grant-tables
And then
set password for 'someone'#'localhost' password('new fancy password')
(notice the '')
See more info in the docs: http://dev.mysql.com/doc/refman/5.0/en/set-password.html
This answer might also help
MySQL - ERROR 1045 - Access denied