首页 > 解决方案 > 为什么在 liquibase 中运行 DIFF 命令时出现用户名错误?

问题描述

尝试运行 Diff 命令时,我相当确定我的命令是正确的,但是每次运行时都会收到“--userName=Root: command not found”错误。没有任何执行。请参阅下面的命令和结果。任何想法以及为什么?请注意,为了便于阅读,我在命令行中添加了换行符,当我输入命令时,它都在一行上。

liquibase 
--driver=com.mysql.cj.jdbc.Driver 
--url=jdbc:mysql://localhost/dev?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC 
--userName=root 
--password=SomePassword 
--logLevel=debug diff 
--referenceUrl=jdbc:mysql://localhost/Prod?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC 
--referenceUsername=root 
--referencePassword=SomePassword
[1] 5437
[2] 5438
[3] 5439
[4] 5440
[5] 5441
[6] 5442
-bash: --userName=root: command not found
-bash: --referenceUsername=root: command not found
[2]   Done                    useJDBCCompliantTimezoneShift=true
[3]   Done                    useLegacyDatetimeCode=false
[5]-  Done                    useJDBCCompliantTimezoneShift=true
[6]+  Done                    useLegacyDatetimeCode=false
[4]+  Exit 127                serverTimezone=UTC --userName=root --password=SomePassword --logLevel=debug diff --referenceUrl=jdbc:mysql://localhost/Prod?useUnicode=true
macbook:~ name$ Starting Liquibase at Wed, 26 Jun 2019 07:22:10 CDT (version 3.6.3 built at 2019-01-29 11:34:48)
Errors:
  No command was passed.

标签: liquibase

解决方案


我怀疑 bash 解析错误。尝试将 url 括在引号中或将整个--url=<connectstring>参数括在引号中。

另一种选择是将参数放入liquibase.properties文件中,这样您就不必在命令行上指定它们。您甚至可以设置不同的属性文件并指定--defaultsFile=</path/to/file>为不同的环境使用不同的文件。如果您不指定该选项,liquibase 将查找名为liquibase.properties


推荐阅读