1

这是我的 MySQL 数据库信息。

这是我的网络服务器托管信息。

    public void readDataBase() throws Exception {
    try {
        // This will load the MySQL driver, each DB has its own driver
        Class.forName("com.mysql.jdbc.Driver");
        // Setup the connection with the DB
        connect = DriverManager
                .getConnection("jdbc:mysql://185.28.21.11/u505743489_db?"+ "user=u505743489_db&password=password");

        // Statements allow to issue SQL queries to the database
        statement = connect.createStatement();
        // Result set get the result of the SQL query
        resultSet = statement
                .executeQuery("select * from FEEDBACK.COMMENTS");
        writeResultSet(resultSet);

        // PreparedStatements can use variables and are more efficient
        preparedStatement = connect
                .prepareStatement("insert into  FEEDBACK.COMMENTS values (default, ?, ?, ?, ? , ?, ?)");
        // "myuser, webpage, datum, summary, COMMENTS from FEEDBACK.COMMENTS");
        // Parameters start with 1
        preparedStatement.setString(1, "Test");
        preparedStatement.setString(2, "TestEmail");
        preparedStatement.setString(3, "TestWebpage");
        preparedStatement.setDate(4, new java.sql.Date(2009, 12, 11));
        preparedStatement.setString(5, "TestSummary");
        preparedStatement.setString(6, "TestComment");
        preparedStatement.executeUpdate();

        preparedStatement = connect
                .prepareStatement("SELECT myuser, webpage, datum, summary, COMMENTS from FEEDBACK.COMMENTS");
        resultSet = preparedStatement.executeQuery();
        writeResultSet(resultSet);

        // Remove again the insert comment
        preparedStatement = connect
                .prepareStatement("delete from FEEDBACK.COMMENTS where myuser= ? ; ");
        preparedStatement.setString(1, "Test");
        preparedStatement.executeUpdate();

        resultSet = statement
                .executeQuery("select * from FEEDBACK.COMMENTS");
        writeMetaData(resultSet);

    } catch (Exception e) {
        throw e;
    } finally {
        close();
    }

}

我尝试了这段代码,但它给出了:
线程“main”中的异常 java.sql.SQLException:null,来自服务器的消息:“Host 'mobile-130-126-255-40.near.illinois.edu' is not allowed to连接到这个 MySQL 服务器”

我搜索了一下,似乎我必须授予数据库权限,但我不知道我的 MySQL 命令提示符在哪里。有没有办法在 phpMyAdmin 中授予权限?
任何帮助,将不胜感激!

4

1 回答 1

1

点击windows+r然后在里面输入“cmd”然后回车。这将打开windows的命令提示符。

然后去.. mysql -u user_name -p press_enter_key

然后输入密码

IE

第 1 行:mysql -u root -h localhost -p

第 2 行:管理员

其中“管理员”是您的密码。

然后..

mysql> 将 databasename.* 上的所有权限授予由“密码”标识的 cmsuser@localhost;

于 2013-11-25T08:31:54.040 回答