- 我正在尝试使用
Liquibase
创建不存在的数据库。 我已经下载了
MySQL
并且没有对其进行任何更改我的 maven 插件代码如下所示
<plugins> <plugin> <groupId>org.liquibase</groupId> <artifactId>liquibase-maven-plugin</artifactId> <version>3.1.1</version> <configuration> <changeLogFile>src/main/resources/changelog.xml</changeLogFile> <driver>com.mysql.jdbc.Driver</driver> <url>jdbc:mysql://localhost:3306/myApp?createDatabaseIfNotExist=true</url> </configuration> <executions> <execution> <phase>process-resources</phase> <goals> <goal>update</goal> </goals> </execution> </executions> </plugin> </plugins>
当我运行 mvn clean install
时,我看到的错误是
Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:update (default) on project database_seed: Error setting up or running Liquibase: liquibase.exception.DatabaseException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database 'myApp' -> [Help 1]
我该如何解决?
最佳答案
看起来您没有将用户名或密码作为配置的一部分传递:
( from the liquibase maven documentation )
<configuration>
<changeLogFile>src/main/resources/changelog.xml</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost:3306/myApp?createDatabaseIfNotExist=true</url>
<username>liquibaseTest</username>
<password>pass</password>
</configuration>
关于java - 如何使用 Liquibase 创建数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23745527/