Java 如何使用 Liquibase 创建数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23745527/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 00:58:40 来源:igfitidea点击:
How to create database with Liquibase
提问by daydreamer
- I am trying to use
Liquibase
to create database that does notexists. I have downloaded
MySQL
and not made any change in itMy maven plugin code looks like
<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>
- 我正在尝试使用
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>
When I run mvn clean install
, I see error as
当我运行时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]
How do I fix it?
我如何解决它?
采纳答案by matt
Looks like you're not passing a username or password as part of your config:
看起来您没有在配置中传递用户名或密码:
(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>