你好,我是MySQL服务器的新手,我想从我的计算机上远程连接MySQL DataBase,而不是放在数据库上!我在有MySQL服务器的机器上的IP是:
39.32.58.13我使用这个代码连接:
private Connection connect = null;
private Statement statement = null;
private PreparedStatement preparedStatement = null;
private ResultSet resultSet = null;
private void Connect(){
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://39.32.222.77:3306/test","myname", "mypass");
}
}但它总是给我一个错误:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.是我做错了什么,因为我是第一次这样做,需要指导如何去做!所以请不要介意我的错误,谢谢
发布于 2014-05-12 08:23:05
您需要授予从远程位置使用mysql的权限。
GRANT ALL PRIVILEGES ON *.* TO 'user'@'%.example.com'
IDENTIFIED BY PASSWORD 'Password'
WITH GRANT OPTION;
FLUSH PRIVILEGES;其中用户可以是root用户或任何其他用户。
有关更多的信息,请参阅此
发布于 2014-05-12 08:26:08
首先,检查远程mysql数据库是否正在运行。第二,检查mysql帐户是否有访问数据库的权限。
希望能帮助你!
https://stackoverflow.com/questions/23604128
复制相似问题