hasura cloud 的 MySQL 数据库连接错误

问题描述 投票:0回答:1

我使用的是hasura云环境。对于 MySQL 数据库,我使用 MySQL Workbench 并创建了一个数据库。我想在 hasura 环境中使用这个数据库。 MySQL 服务器已启动并在端口 3306 上运行。 我的 JDBC 连接字符串是:

jdbc:mysql://localhost:3306/employees?user=admin&password=password@123
连接后出现这个错误

[
    {
        "definition": "employees",
        "message": {
            "stacktrace": "com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)\n\tat com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)\n\tat com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:828)\n\tat com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:448)\n\tat com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241)\n\tat com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)\n\tat io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:226)\n\tat io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:536)\n\tat io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:517)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat java.base/java.lang.Thread.run(Thread.java:833)\nCaused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.\n\tat jdk.internal.reflect.GeneratedConstructorAccessor53.newInstance(Unknown Source)\n\tat java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)\n\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)\n\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)\n\tat com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)\n\tat com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)\n\tat com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)\n\tat com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)\n\tat com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:89)\n\tat com.mysql.cj.NativeSession.connect(NativeSession.java:120)\n\tat com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:948)\n\tat com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:818)\n\t... 11 more\nCaused by: java.net.ConnectException: Connection refused\n\tat java.base/sun.nio.ch.Net.connect0(Native Method)\n\tat java.base/sun.nio.ch.Net.connect(Net.java:579)\n\tat java.base/sun.nio.ch.Net.connect(Net.java:568)\n\tat java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:593)\n\tat java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)\n\tat java.base/java.net.Socket.connect(Socket.java:633)\n\tat com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:153)\n\tat com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:63)\n\t... 14 more\n"
        },
        "name": "source employees",
        "reason": "Inconsistent object: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.",
        "type": "source"
    }
]

云环境是否允许使用本地SQL数据库?或者我们是否必须使用云端的 MySQL 数据库。 我有一个小小的疑问。密码有问题吗,因为它包含

@
符号!

mysql graphql database-connection connection-string hasura
1个回答
0
投票
Hasura Cloud 上的

localhost
将指向 Hasura Cloud 基础设施内运行的容器的本地网络

由于您的 MySQL 数据库没有与 Hasura Cloud 引擎实例一起运行,因此您需要向 Hasura 提供从云网络内部看到的数据库地址。

这将是外部 IP 地址或域名。

© www.soinside.com 2019 - 2024. All rights reserved.