如何使用Liquibase创建数据库 [英] How to create database with Liquibase

查看:851
本文介绍了如何使用Liquibase创建数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我正在尝试使用Liquibase创建存在的数据库.
  • 我已经下载了MySQL并且未进行任何更改

  • I am trying to use Liquibase to create database that does not exists.
  • I have downloaded MySQL and not made any change in it

我的maven插件代码如下

My 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>

运行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]

我该如何解决?

推荐答案

好像您没有在配置中传递用户名或密码:

Looks like you're not passing a username or password as part of your config:

( )

<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>

这篇关于如何使用Liquibase创建数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆