“Access denied for user ‘hp’@’localhost’ (using password: NO) in SpringBoot application.”

huangapple go评论67阅读模式
英文:

Access denied for user 'hp'@'localhost' (using password: NO) in SpringBoot application

问题

尝试使用我的SpringBoot应用连接MySQL服务器时遇到上述问题,请有人能提供建议吗?

spring.datasource.url=jdbc:mysql://localhost:3306/myblog
spring.datasource.username=Admin
spring.datasource.password=Admin

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=update

错误如下:

java.sql.SQLException: 用户 'hp'@'localhost' 拒绝访问使用密码NO
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:130) ~[mysql-connector-j-8.0.33.jar:8.0.33]
	// 其他错误信息...
英文:

Trying to connect with MySQL server with my SpringBoot application but facing above issue, can someone suggest?

spring.datasource.url=jdbc:mysql://localhost:3306/myblog
spring.datasourse.username=Admin
spring.datasourse.password=Admin

spring.jpa.properties.hibernate.dailect=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=update 

Error as per below

java.sql.SQLException: Access denied for user 'hp'@'localhost' (using password: NO)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:130) ~[mysql-connector-j-8.0.33.jar:8.0.33]
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-j-8.0.33.jar:8.0.33]
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825) ~[mysql-connector-j-8.0.33.jar:8.0.33]
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:446) ~[mysql-connector-j-8.0.33.jar:8.0.33]
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:239) ~[mysql-connector-j-8.0.33.jar:8.0.33]
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:188) ~[mysql-connector-j-8.0.33.jar:8.0.33]
	at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121) ~[HikariCP-5.0.1.jar:na]
	at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) ~[HikariCP-5.0.1.jar:na]
	at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) ~[HikariCP-5.0.1.jar:na]
	at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) ~[HikariCP-5.0.1.jar:na]
	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[HikariCP-5.0.1.jar:na]
	at co

答案1

得分: 1

错误提示显示用户“hp”,但您的属性显示用户“Admin”。另外,密码不匹配。您的应用程序正在使用错误的凭据。对于安全性来说,两个密码的质量都非常糟糕是另一个问题。

英文:

The error says user "hp" but your properties say user "Admin". Also the password doesn't match. Your applications is using the wrong credentials. That both passwords have very bad quality for security is a different issue.

答案2

得分: 0

请检查数据源的拼写错误:

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/db?createDatabaseIfNotExist=true
spring.datasource.username=root //your db user name
spring.datasource.password=root //your db user password
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
#如果您的 MySql 版本是 5,请使用 MySQL5Dialect
spring.data.jpa.repositories.enabled=true
spring.jpa.show-sql=true
spring.jpa.database=mysql

英文:

Kindly check the spelling mistake of datasource:

spring.jpa.hibernate.ddl-auto=update  
spring.datasource.url=jdbc:mysql://localhost:3306/db?createDatabaseIfNotExist=true   
spring.datasource.username=root  //your db user name  
spring.datasource.password=root  //your db user password 
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect  
#If your MySql version 5 then use MySQL5Dialect
spring.data.jpa.repositories.enabled=true
spring.jpa.show-sql=true
spring.jpa.database=mysql

答案3

得分: 0

数据源 -> 数据源
方言 -> 方言
英文:

Typo alert!!

datasourse -> datasource
dailect -> dialect

huangapple
  • 本文由 发表于 2023年5月18日 01:42:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76274843.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定