简体   繁体   中英

Unable to create initial pool of connections in springboot

I am trying to connect a database with the springboot but that is not running in any way. I have made about 3 applications till now but all have the same issue. I am a total spring newbie and working for the first time.

I have used JPA and Mysql for the application but all the time the error will show itself.

application file

  datasource:
    url: jdbc:mysql://localhost:3306/test_schema
    username: root
    password: user
  jpa:

    generate-ddl: true
    show-sql: true

Error

Sat Jun 08 11:02:13 IST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2019-06-08 11:02:13.362 ERROR 14040 --- [           main] o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.

java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'.
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:868) ~[mysql-connector-java-5.1.41.jar:5.1.41]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:864) ~[mysql-connector-java-5.1.41.jar:5.1.41]
    at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1746) ~[mysql-connector-java-5.1.41.jar:5.1.41]
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226) ~[mysql-connector-java-5.1.41.jar:5.1.41]
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2205) ~[mysql-connector-java-5.1.41.jar:5.1.41]
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2236) ~[mysql-connecto......

Error continues and is really a very long list

I have asked a similar question before but that solved the problem of database schema and table but now this is showing up . And this error is showing in almost all the applications. Mysql is up and running. The username password are correct. The database also has some initial entries.

在mysql服务器上运行此命令:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'user';

caching_sha2_password is the default authentication plugin for MySQL. Please try updating the mysql connector library to say mysql-connector-java-8.0.12 ( try to match mysql version and connector version ) Probably yo are using version around "5.1.44".

Also, if this doesnt work, try as what is suggested above

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'user';

If the change fixes this issue but leads to a different exception : java.sql.SQLException: Unknown system variable 'query_cache_size' , it probably indicates the version of mySQL connector is not correct/matching for MySQL 8x versions

Remember, "The query cache is deprecated as of MySQL 5.7.20, and is removed in MySQL 8.0"

Update the dependency for MYSQL connector library to use latter versions, latest on date is 8.0.15:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.15</version>
</dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM