Skip to content
Advertisement

Access denied for user ‘root ‘@’localhost’ ” when connecting to mysql

I try to connect to a mysql database in a spring project and error occurred.

JavaScript

The configuration in application.properties is

JavaScript

In pom.xml is

JavaScript

I’m sure the password is correct. And in cmd I tried following command and it work.

JavaScript

So what’s the possible reason? Thx.

Advertisement

Answer

Remove the spaces on the sides of the = signs in your application.properties. And also make sure you have no spaces after the values (notice in your question title it’s trying to log in as root with a space after the t).

You do have spaces after root in the copy/pasted data in the question (couldn’t possibly know in your real file)

Look at a screenshot of your question with the text selected (notice after root):

Copy/paste spaces image

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement