Access denied for user 'root'@'localhost' (using password: YES), SpringBoot integrated mybatis error

The original code of my application.yml is this:

server:
  port: 8080
spring:
  application:
    name: springBoot_mybatis
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/xlr
    username: root
    password: 123456

Then report an error:

After checking various methods, there is no solution. Finally, I saw the picture in this blog , added quotation marks after username and password, and changed it to the following:

server:
  port: 8080
spring:
  application:
    name: springBoot_mybatis
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/xlr
    username: "root"
    password: "123456"

successfully passed! ! !

Of course, my method may not be applicable to all situations.

Guess you like

Origin blog.csdn.net/m0_61465701/article/details/127453683