Liquibase 无法连接到 SQL 服务器
Liquibase can't connect to the SQL Server
我对 liquibase 还很陌生,并尝试在我自己的计算机上设置它,运行 Windows 7 使用本地 MySQL 服务器。我已经安装了 JDBC 驱动程序 (4.2),在我的防火墙和服务器上打开了 TCP/IP 端口 3306,安装了 liquibase 并将其添加为环境变量中的 PATH。
作为我尝试使用的第一个命令:
C:\Users\Marius>H:\Liquibase\Liquibase \
--driver=com.microsoft.sqlserver.jdbc.SQLServerDriver \
--classpath="C:\Program Files\Microsoft JDBC Driver 6.2 for SQL Server\sqljdbc_6.2\enu\mssql-jdbc-6.2.2.jre7.jar" \
--url="jdbc:sqlserver://localhost:3306; databaseName=Test" \
--changeLogFile="H:\Liquibase\dbchangelog.xml" \
--username=liquibase \
--password=liquibase \
Update
但是执行时我只得到:
Unexpected error running Liquibase:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection
to the host localhost, port 3306 has failed. Error: "Connection
refused: connect. Verify the connection properties. Make sure that an
instance of SQL Server is running on the host and accepting TCP/IP
connections at the port. Make sure that TCP connections to the port
are not blocked by a firewall.".
服务器肯定是 运行,因为我可以使用 telnet、mySQLWorkbench 和其他几个工具连接到它。
当 运行 命令带有 --url="jdbc:sqlserver:localhost:3306; databaseName=Test"
时,我得到一个不同的错误代码。
Unexpected error running Liquibase:
liquibase.exception.DatabaseException: Connection could not be created
to jdbc:sqlserver:localhost:3306; databaseName=Test with driver
com.microsoft.sqlserver.jdbc.SQLServerDriver. Possibly the wrong
driver for the given database URL
我在另一台装有 SQL Server 2017、不同的 JDBC 驱动程序(6.0 和 6.2)和 Windows 10 作为 OS 的计算机上再次尝试了此操作。
停用防火墙没有任何作用,全新安装也没有任何作用。
感谢任何帮助。
MySQL 是与 Microsoft SQL Server 不同的产品。鉴于您已经说过可以使用 MySQL workbench 进行连接,这可能是您安装的产品。
与其尝试连接到不存在的 Microsoft SQL 服务器,不如尝试使用 MySQL 驱动程序。
我对 liquibase 还很陌生,并尝试在我自己的计算机上设置它,运行 Windows 7 使用本地 MySQL 服务器。我已经安装了 JDBC 驱动程序 (4.2),在我的防火墙和服务器上打开了 TCP/IP 端口 3306,安装了 liquibase 并将其添加为环境变量中的 PATH。
作为我尝试使用的第一个命令:
C:\Users\Marius>H:\Liquibase\Liquibase \
--driver=com.microsoft.sqlserver.jdbc.SQLServerDriver \
--classpath="C:\Program Files\Microsoft JDBC Driver 6.2 for SQL Server\sqljdbc_6.2\enu\mssql-jdbc-6.2.2.jre7.jar" \
--url="jdbc:sqlserver://localhost:3306; databaseName=Test" \
--changeLogFile="H:\Liquibase\dbchangelog.xml" \
--username=liquibase \
--password=liquibase \
Update
但是执行时我只得到:
Unexpected error running Liquibase: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 3306 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
服务器肯定是 运行,因为我可以使用 telnet、mySQLWorkbench 和其他几个工具连接到它。
当 运行 命令带有 --url="jdbc:sqlserver:localhost:3306; databaseName=Test"
时,我得到一个不同的错误代码。
Unexpected error running Liquibase: liquibase.exception.DatabaseException: Connection could not be created to jdbc:sqlserver:localhost:3306; databaseName=Test with driver com.microsoft.sqlserver.jdbc.SQLServerDriver. Possibly the wrong driver for the given database URL
我在另一台装有 SQL Server 2017、不同的 JDBC 驱动程序(6.0 和 6.2)和 Windows 10 作为 OS 的计算机上再次尝试了此操作。 停用防火墙没有任何作用,全新安装也没有任何作用。
感谢任何帮助。
MySQL 是与 Microsoft SQL Server 不同的产品。鉴于您已经说过可以使用 MySQL workbench 进行连接,这可能是您安装的产品。
与其尝试连接到不存在的 Microsoft SQL 服务器,不如尝试使用 MySQL 驱动程序。