<分区>
我正在尝试通过 NetBeans 从 Java 使用 MySQL 数据库(安装在我的电脑上的虚拟机 (Debian) 上并且具有 IP 地址 192.168.1.5
)。
我已经配置连接如下:
Driver Name MySQL(Connector/J Driver)
Host 192.168.1.5
Database test
Username root
Password *
JDBC URL jdbc:mysql://192.168.1.5:3306/test
然后我得到以下错误:
cannot establish a connection to jdbc:mysql://192.168.1.5:3306/test using
com.mysql.jdbc.Driver (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.)
我的 mysql.user
表看起来像这样(我知道 % root
不是很安全,但这只是为了暂时简化事情):
+------------+------------------+
| host | user |
+------------+------------------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
| debVirtual | |
| localhost | |
| localhost | debian-sys-maint |
| localhost | phpmyadmin |
| localhost | root |
+------------+------------------+
我该怎么做才能允许此连接?