如何使用java来处理远程mysql数据库? [英] How to connent to a remote mysql database with java?

查看:123
本文介绍了如何使用java来处理远程mysql数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Eclipse IDE创建一个JSF应用程序。我使用远程mySQL服务器作为我的数据库。如何连接到这个远程数据库来创建表格并访问它们?

I am trying to create a JSF application using the Eclipse IDE. I am using a remote mySQL server as my database. How do I connect to this remote database for creating tables and accessing them?

推荐答案

只需提供远程机器的IP /主机名在数据库连接字符串中,而不是 localhost 。例如:

Just supply the IP / hostname of the remote machine in your database connection string, instead of localhost. For example:

jdbc:mysql://192.168.15.25:3306/yourdatabase

确保没有防火墙阻止访问端口 3306

Make sure there is no firewall blocking the access to port 3306

此外,请确保您正在连接的用户可以从此特定的主机名进行连接。对于开发环境,可以通过'username'@'%'来做到这一点。检查用户创建手册 GRANT 手册

Also, make sure the user you are connecting with is allowed to connect from this particular hostname. For development environments it is safe to do this by 'username'@'%'. Check the user creation manual and the GRANT manual.

这篇关于如何使用java来处理远程mysql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆