gpt4 book ai didi

java - 我无法在 netbeans 和 apache 服务器中使用 java 连接到远程数据库

转载 作者:行者123 更新时间:2023-12-02 03:40:09 25 4
gpt4 key购买 nike

我正在尝试远程连接到我的 apache 服务器。我设法允许使用我的 IP 访问我的数据库和服务器,但是当我尝试使用集成的 netbeans 连接工具测试与我的数据库的连接时,我只能使用我的本地主机访问它

我尝试在 apache 中设置绑定(bind)地址,但这破坏了我的服务器,我每次都需要重新安装它。我还为我的用户添加了完整的权限,并且可以使用单独的 IP 访问它。

#
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
Require local
Require ip xxx.xxx.xxx.xxx (my ip)
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>
("jdbc:mysql://xxx.xxx.xxx.xxx:3306/dbname", "root", "password");
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.

错误日志:

2019-07-03 18:55:56 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2019-07-03 18:55:56 0 [Note] InnoDB: Uses event mutexes
2019-07-03 18:55:56 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-07-03 18:55:56 0 [Note] InnoDB: Number of pools: 1
2019-07-03 18:55:56 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-07-03 18:55:56 0 [Note] InnoDB: Initializing buffer pool, total size = 16M, instances = 1, chunk size = 16M
2019-07-03 18:55:56 0 [Note] InnoDB: Completed initialization of buffer pool
2019-07-03 18:55:56 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=1797710
2019-07-03 18:55:56 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-07-03 18:55:56 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-07-03 18:55:56 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-07-03 18:55:56 0 [Note] InnoDB: Setting file 'C:\xampp\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-07-03 18:55:56 0 [Note] InnoDB: File 'C:\xampp\mysql\data\ibtmp1' size is now 12 MB.
2019-07-03 18:55:56 0 [Note] InnoDB: Waiting for purge to start
2019-07-03 18:55:56 0 [Note] InnoDB: 10.3.16 started; log sequence number 1797719; transaction id 225
2019-07-03 18:55:56 0 [Note] InnoDB: Loading buffer pool(s) from C:\xampp\mysql\data\ib_buffer_pool
2019-07-03 18:55:56 0 [Note] InnoDB: Buffer pool(s) load completed at 190703 18:55:56
2019-07-03 18:55:56 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-07-03 18:55:56 0 [Note] Server socket created on IP: 'xxx.xxx.xxx.xxx'.
2019-07-03 18:55:56 0 [ERROR] Can't start server: Bind on TCP/IP port. Got error: 10049: The requested address is not valid in its context.


2019-07-03 18:55:56 0 [ERROR] Do you already have another mysqld server running on port: 3306 ?
2019-07-03 18:55:56 0 [ERROR] Aborting

最佳答案

您允许远程访问 Apache 服务器,但不允许远程访问 MySQL 服务器。要允许远程访问 MySQL,您需要修改 my.cnf:

[mysqld]
...
bind-address = xxx.xxx.xxx.xxx

有关详细说明,请参阅此处的示例:https://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

关于java - 我无法在 netbeans 和 apache 服务器中使用 java 连接到远程数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56840595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com