Tag Archives: java.sql.SQLException: Access denied for user ‘${user}’@’localhost’ (using password: YES)

[Solved] Spring Error: java.sql.SQLException: Access denied for user ‘${user}’@’localhost’ (using password: YES)

Spring properties configuration file problem

error message

Spring loads JDBC Error in properties content, original configuration file:

Error message:

Solution:

When connecting to the database, the role name of root should be root@localhost. The role name of root reporting error here is Sang@localhost , sang here is the user name of idea. When idea loads root, it automatically replaces root with sang, so use Sang@localhost An error will be reported when connecting to the database.

Solution 1: modify the configuration file to

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/hellospring?serverTimezone=UTC
user=root
password=123456

Modification method 2: modify the configuration file to

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/hellospring?serverTimezone=UTC
jdbc.username=root
jdbc.password=123456