我正在尝试通过192.168.1.5
使用 NetBeans 从 Java 使用 MySQL 数据库(安装在我的电脑上的虚拟机(Debian)上并具有 IP 地址)。
我已将连接配置如下:
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 |
+------------+------------------+
我该怎么做才能允许这种连接?