2014-05-19 53 views
3
  • 創建數據庫,我試圖用Liquibase創建數據庫,做不存在
  • 我已經下載MySQL並沒有作出任何改變它如何使用Liquibase

  • 我的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] 

我該如何解決?

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

如果您正在使用的配置application.properties春季啓動,請使用以下鍵值對: 'spring.datasource.url =的jdbc:mysql的://本地主機:11030/myAppcreateDatabaseIfNotExist = TRUE; ' spring.datasource.username = liquibaseTest' 'spring.datasource.password = pass' – realPK