无法在springboot中创建初始连接池

时间:2019-06-08 05:37:52

标签: java mysql spring spring-boot jpa

我正在尝试用springboot连接数据库,但是它没有以任何方式运行。到目前为止,我已经提出了大约3个应用程序,但是都存在相同的问题。我是一个春季新手,并且是第一次工作。

我已经为应用程序使用了JPA和Mysql,但始终都会显示错误。

应用程序文件

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

    generate-ddl: true
    show-sql: true

错误

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

我之前曾问过类似的问题,但是解决了数据库架构和表的问题,但是现在出现了。而且几乎所有的应用程序都显示此错误。 Mysql已启动并正在运行。用户名密码正确。该数据库还具有一些初始条目。

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

caching_sha2_password 是MySQL的默认身份验证插件。 请尝试更新mysql连接器库,使其显示mysql-connector-java-8.0.12(尝试匹配mysql版本和连接器版本) 可能您正在使用“ 5.1.44”附近的版本。

此外,如果这不起作用,请按照上面的建议尝试

struct Pixel {
    let red: UInt8
    let green: UInt8
    let blue: UInt8
    let alpha: UInt8
}

extension Pixel {
    var color: UIColor {
        return UIColor(red: CGFloat(red) / 255,
                       green: CGFloat(green) / 255,
                       blue: CGFloat(blue) / 255,
                       alpha: CGFloat(alpha) / 255)
    }
}

如果更改解决了此问题,但导致了另一个异常: java.sql.SQLException:未知的系统变量'query_cache_size',则可能表明mySQL连接器的版本不正确/与之匹配MySQL 8x版本

请记住,“自MySQL 5.7.20起已弃用查询缓存,而在MySQL 8.0中已将其删除”

将MYSQL连接器库的依赖关系更新为使用更高版本,最新日期为8.0.15:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'user';
相关问题