Springboot connects docker's mysql error Access denied for user'root'@'192.168.56.1' (using password: NO)

1. Problem: The error IP is not the IP of my database container, but the IP configured by VirtualBox

  • java.sql.SQLException: Access denied for user ‘root’@‘192.168.56.1’ (using password: NO)
    Insert picture description here
  • Original configuration in springBoot
spring.datasource.data-password=123456
spring.datasource.data-username=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.56.5:3306/XXX

2. Solve

  • The reason is that there is an extra data in username and password. I didn't pay attention to it when I quoted it. Just change it.
spring.datasource.password=123456
spring.datasource.username=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.56.5:3306/XXX

Guess you like

Origin blog.csdn.net/JISOOLUO/article/details/104403601