๐Ÿ”ด The Error You're Seeing

Confirm this matches your console output. If it does, you're in the right place.

ERROR LOG2026-02-14 17:25:12.000 ERROR 8842 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization. java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) at com.zaxxer.hikari.pool.HikariPool.newConnection(HikariPool.java:345)

โšก Quick Fix Works 80% of the time

Verify the spring.datasource.username and spring.datasource.password in application.properties.

spring.datasource.username=root spring.datasource.password=your_correct_password

๐Ÿ› ๏ธ Solutions (3 Ways to Fix)

Solution 1โœ“ Most common cause

Fix the password in application.properties

๐Ÿ‘‰ Use this if you recently changed your DB password or copied the project from another machine.

The 'using password: YES' part of the error means Spring sent a password, but it was incorrect. Update it to match the DB.

spring.datasource.username=root spring.datasource.password=mySecretPassword123
Solution 2

Remove trailing spaces from the URL/credentials

๐Ÿ‘‰ Use this if you are 100% sure the password is correct but it still fails.

A hidden space at the end of the username or password in properties files is a very common cause of authentication failures.

# Bad (trailing space after root) # spring.datasource.username=root # Good spring.datasource.username=root
Solution 3

Grant privileges to the database user

๐Ÿ‘‰ Use this if the user exists but doesn't have permission to access the specific database.

Log into your database via command line and grant all privileges to the user for that specific schema.

-- Log into MySQL/Postgres as admin GRANT ALL PRIVILEGES ON mydb.* TO 'root'@'localhost'; FLUSH PRIVILEGES;

๐Ÿ“‹ Version Notes

Spring Boot 2.x

Standard JDBC authentication error.

Spring Boot 3.x

Standard JDBC authentication error. MySQL connector uses com.mysql.cj.jdbc.exceptions.SQLError.

๐Ÿง  Why this Happens

Tap to expand the deep technical explanation

Spring Boot successfully connected to the database server (unlike Connection Refused), but the database server rejected the username and password combination you provided.

The HITEC City Parking Spot Analogy:

It is like using the wrong PIN at an ATM. The ATM (database server) is working, but it refuses to give you access to the money because your credentials are wrong.

๐Ÿ›ก๏ธ How to Prevent This Next Time

Store database credentials in environment variables (e.g., ${DB_PASSWORD}) rather than hardcoding them, to prevent typos during deployments.

Course Search
Search across all chapters & stages
๐Ÿ“–

Search the course

Type any topic โ€” branching, stash, rebase, hooks โ€” and jump straight to that chapter.

merge branchesgit stashundo commitrebase