[Solved] Access denied for user ‘Administrator’@’localhost’ (using password: YES)

The reason is that there is also a username property in the system. At this time, the system variable overwrites the value in Properties. At this time, the username value is obtained as the system user name Administrator, and the password is the password in properties to query the database. At this time, the user name and password If it does not match, an error will be reported. When Spring completes the injection, it uses the “${..}” method to get the value to complete the injection. And through this expression, the JVM system properties can also be directly obtained……….


Solution 1: Replace the username in the properties file with user or other strings to successfully obtain a connection to access the database. Suggestion: When username is a sensitive word, try not to use username for the sake of safety.

Solution 2: Modify the Spring configuration file to: <context:property-placeholder location=”classpath:/jdbc.properties” system-properties-mode=”FALLBACK / NEVER”/>

Add a system-properties-mode property

This attribute has three values:

FALLBACK — default value, overwrite if it does not exist

NEVER — do not cover

OVERRIDE — cover

Similar Posts: