如何使用Liquibase创建数据库

时间:2014-05-19 19:17:21

标签: java mysql maven liquibase

  • 我正在尝试使用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]

我该如何解决?

1 个答案:

答案 0 :(得分:8)

您似乎未在配置中传递用户名或密码:

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>