首页 > 解决方案 > Liquibase 无法使用用户名和密码读取 jdbc postegresql 连接字符串

问题描述

Liquibase 网站上的文档说我可以在--url参数中使用完整的连接字符串,例如

jdbc:postgresql://host:port/database?user=user&password=secret

但是当我运行任何命令时,例如

liquibase history --url='jdbc:postgresql://host:port/database?user=user&password=secret'

我收到以下错误:

Unexpected error running Liquibase: Connection could not be created to jdbc:postgresql://host:5432/database?user=user with driver org.postgresql.Driver.  The server requested password-based authentication, but no password was provided.

For more information, please use the --log-level flag
'password' is not recognized as an internal or external command,
operable program or batch file.

看起来&Liquibase 将连接字符串拆分为两个命令。如果我单独提供--userand--password参数,它会起作用:liquibase history --url='jdbc:postgresql://host:port/database --user='user' --password='secret'

难道我做错了什么?我在 PowerShell 中运行它。

标签: liquibase

解决方案


您的连接字符串应类似于:

postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]

所以应该是:

liquibase history --url='jdbc:postgresql://user:password@host:port/database'

感谢https://stackoverflow.com/a/20722229/2864019


推荐阅读