本文介绍了如何使用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?

推荐答案

只需在数据库连接字符串(而不是localhost)中提供远程计算机的IP/主机名.例如:

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数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 00:09