skip to Main Content

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

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search