无法创建连接:无法连接:客户端不支持服务器请求的身份验证协议

时间:2018-04-03 13:39:28

标签: java mysql mariadb

从maria db获取连接时出现以下错误:

DEBUG com.utilities.db.ConnectionPoolImpl - Exception Occured in connection: Cannot create connection:Could not connect: Client does not support authentication protocol requested by server; consider upgrading MariaDB client
Exception in thread "Thread-1" java.lang.IllegalMonitorStateException
        at java.lang.Object.notifyAll(Native Method)
        at com.utilities.db.ConnectionPoolImpl.run(ConnectionPoolImpl.java:128)
        at java.lang.Thread.run(Thread.java:745)


+-------------------------+--------------------------+
| Variable_name           | Value                    |
+-------------------------+--------------------------+
| innodb_version          | 5.6.35-80.0              |
| protocol_version        | 10                       |
| slave_type_conversions  |                          |
| version                 | 10.1.23-MariaDB-9+deb9u1 |
| version_comment         | Raspbian 9.0             |
| version_compile_machine | armv7l                   |
| version_compile_os      | debian-linux-gnueabihf   |
| version_malloc_library  | system jemalloc          |
| version_ssl_library     | YaSSL 2.4.2              |
| wsrep_patch_version     | wsrep_25.19              |
+-------------------------+--------------------------+

我正在使用java连接到db。

Class.forName("org.drizzle.jdbc.DrizzleDriver");

Connection connection = DriverManager.getConnection(""jdbc:drizzle://" + ADDRESS + ":" + PORT + "/" + DB", userName, password);

Connection connection = DriverManager.getConnection(
                        "jdbc:drizzle://" + DBProperties.ADDRESS + ":" + DBProperties.PORT + "/?allowMultiQueries=true",
                        DBProperties.USER, DBProperties.PASS)

<dependency>
        <groupId>org.drizzle.jdbc</groupId>
        <artifactId>drizzle-jdbc</artifactId>
        <version>1.4</version>
    </dependency>

我不知道为什么我能得到这个能有人帮助我吗?

1 个答案:

答案 0 :(得分:1)

请尝试按照https://mariadb.com/kb/en/library/about-mariadb-connector-j/

中的建议操作

我会从您的maven依赖项中删除drizzle驱动程序并包含最新版本的mariaDB连接器

<dependency>
    <groupId>org.mariadb.jdbc</groupId>
    <artifactId>mariadb-java-client</artifactId>
    <version>2.2.3</version>
</dependency>

然后我会替换官方示例的客户端代码:

Connection connection = DriverManager.getConnection("jdbc:mariadb://localhost:3306/DB?user=foo&password=bar");

使用适当的端口,用户等值。我希望你发现它很有用