Spring Boot pit connection Mysql 8.0-

SpringBoot connection mysql8.0 version - pit

In the most recent study Mu class network course - " two hours the Boot quick start the Spring ", an error occurs when using a spring boot connect to the database. Because the teacher's version 5.7 database, my database version 8.0, which in the case of Yihuhuhuapiao, the emergence of a database connection error, google countless content, has finally found a way to solve the problem in the vast network.

wrong description

Error : database connection, the need to configure the application-dev.yml file, the configuration file as follows:

server:
  port: 8081
  servlet:
    context-path: /luckymoney

limit:
  minMoney: 0.01
  maxMoney: 9999
  description: 最少要发${limit.minMoney},最多要发${limit.maxMoney}spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/luckymoney
    username: root
    password: 0625
  jpa:
    hibernate:
      ddl-auto: create
    show-sql: true

Error contents:

Here Insert Picture Description

Then find the appropriate content on the Internet, in fact, about the time zone errors There are many solutions. I was able to find a solution to the problem is to modify spring.datasource.url

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/luckymoney?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=true

即添加:?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=true

Solves the problem, run the program again, still being given:

Error content:
Here Insert Picture Description
This time the connection pool or initialization errors, but the problem is it takes a lot of time to find. In the solutions given below.

solution

The database password enclosed in single quotes , that's solved. But I need more specific principles to understand why springboot that when mysql 8.0 version connection password to use single quotes. (As if the password is not so enclosed need? But also a solution)

...
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/luckymoney?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=true
    username: root
    password: '0625'
...

Here Insert Picture Description
This time can be the perfect start up!

reference:

  1. Reference -csdn
Published 16 original articles · won praise 2 · Views 1281

Guess you like

Origin blog.csdn.net/yx185/article/details/100023658