1
kfll 2014-08-31 03:16:52 +08:00 via Android
…我不懂jdbc……路过的时候看到个好奇的点想问一下……mysql的这个url,用户名密码是可以写在query里面的么…不是一般都写在authorization的么,像 jdbc:mysql://utest:[email protected]:9999/test 这样的…
|
2
showhand 2014-08-31 07:20:49 +08:00 via Android
是不是还需要开放其他端口
|
3
showhand 2014-08-31 07:30:37 +08:00 via Android
额,不需要,抓个包看看呢
|
4
showhand 2014-08-31 07:36:10 +08:00 via Android
|
5
lightening 2014-08-31 07:40:09 +08:00
你确定你的 MySQL 允许了远程访问?
|
6
lu18887 2014-08-31 09:17:52 +08:00
至少在VMWARE里,NAT下宿主机是看不到虚拟机的,想要达到宿主机和虚拟机可以相互通讯,可以考虑Host Only或者Bridge
|
7
ptyfork 2014-08-31 09:38:56 +08:00
@lu18887 我用的VMware Fusion 使用NAT方式, 宿主机可以访问没问题的。
启动虚拟机后宿主机上能看到这几个接口 vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 00:50:56:c0:00:01 inet 192.168.232.1 netmask 0xffffff00 broadcast 192.168.232.255 vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 00:50:56:c0:00:08 inet 172.16.109.1 netmask 0xffffff00 broadcast 172.16.109.255 虚拟机的IP地址是 172.16.109.141 Darren-rMBP:~ darren$ ssh [email protected] Linux debian 3.14-2-amd64 #1 SMP Debian 3.14.15-2 (2014-08-09) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Sun Aug 31 09:28:18 2014 from 172.16.109.1 debian:~# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:0c:29:cb:53:90 inet addr:172.16.109.141 Bcast:172.16.109.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fecb:5390/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:143 errors:0 dropped:0 overruns:0 frame:0 TX packets:110 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:18014 (17.5 KiB) TX bytes:20240 (19.7 KiB) |
8
soruNis OP 谢谢回复
1 虚拟机的 3306 端口已经映射到宿主机的 9999 端口 2 通过宿主机的 9999 端口已经可以用 mysql 客户端正确链接 3 用原文中的 java code 调 jdbc 去链接则报错网络错误 |
9
undeflife 2014-08-31 10:06:56 +08:00
看看host跟guest的时间
|
10
Actrace 2014-08-31 10:23:20 +08:00
Mac的NAT一直都有一些奇怪的毛病。
|
11
andy 2014-08-31 11:50:15 +08:00
|
13
soruNis OP 把 mysql-java-connector 升级到最新 (5.1.32), 问题解决了...
背后的具体原因仍不清楚, 如有知悉, 还望大虾不吝赐教~ |