从本地计算机连接到AWS远程mariadb服务器

时间:2018-08-31 08:58:38

标签: amazon-web-services mariadb

我正在尝试从本地计算机连接到AWS机器中安装的MariaDB。 从本地计算机为该计算机打开了3306端口。

我已经在AWS机器的/etc/my.cnf.d/server.cnf文件中设置了bind-address=0.0.0.0,并且还为3306设置了安全组

在我的本地计算机上,当我执行以下Java代码时,

`

    Connection conn = null;

    Class.forName("org.mariadb.jdbc.Driver");

    //STEP 3: Open a connection
    System.out.println("Connecting to a selected database...");
    conn = DriverManager.getConnection(
            "jdbc:mariadb://ip:3306/DB", "username", "password");
    System.out.println("Connected database successfully...");

给出以下错误:

  java.sql.SQLNonTransientConnectionException: Could not connect to ip:3306 : Connection reset
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:175)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:110)
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1113)
at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:503)
at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:155)
at org.mariadb.jdbc.Driver.connect(Driver.java:86)

0 个答案:

没有答案