1
I created a test project by Spring Tool Suite to create a REST server that will connect with a local mysql database, when I start the application it error when trying to connect with mysql: java.sql.Sqlexception: Access denied for user ''@'localhost' (using password: NO)
I find it strange that he didn’t try with the root user I set up in the project.
The application.properties is thus:
spring.jpa.show-sql=true
spring.jpa.database=mysql
spring.datasource.url=jdbc:mysql://localhost/users
spring.datasource.data-username=root
spring.datasource.data-password=12345
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
And pom.xml is like this:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
In the database I executed the following command:
GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '12345';
After running I stopped and started mysql.
From what I understand, this root access command on all tables and from anywhere.
I find it strange that in the error it appears '@'localhost 'instead of root.
Is it the connection config. that is wrong, the pom.xml or the database ?
The problem was in the configuration: spring.datasource.username = root spring.datasource.password = 12345 Put this and solved! Thanks!
– user2831852