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

    10-13 06:54