在空的mysql实例上使用liquibase创建数据库 [英] Create databases with liquibase on empty mysql instance

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

问题描述

我有新鲜的mysql实例,并希望能够创建大量数据库并用liquibase填充它. 虽然我有一些脚本(变更集)在手动创建的数据库上可以正常工作,但我也希望能够使用liquibase创建数据库. 当我尝试不指定URL中的数据库就进行连接时,出现错误:

I have fresh mysql instance and want to be able to create a plenty of databases and populate it with liquibase. While I have scripts (changesets) which works fine on manually created databases I want to be able to create databases with liquibase as well. When I try to connect without specifing database in URL I've got the error:

liquibase --driver=com.mysql.jdbc.Driver --url=jdbc:mysql://localhost:3306/ --username=root --password=admin --changeLogFile=create_dbs.sql tag empty
Unexpected error running Liquibase: Incorrect database name '' [Failed SQL: CREATE TABLE ``.DATABASECHANGELOGLOCK (ID INT NOT NULL, LOCKED BIT(1) NOT NULL, LOCKGRANTED datetime NULL, LOCKEDBY VARCHAR(255) NULL, CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID))]

我不需要由liquibase跟踪这些更改(数据库创建),似乎我想使用LB作为快速引导工具.

I don't need these changes (database creation) to be tracked by liquibase, seems like I want to use LB as quick bootstrap tool.

推荐答案

非常需要首先在URL中添加数据库名称,例如jdbc:mysql://localhost:3306/database_name.

Very first need to add database name in URL like jdbc:mysql://localhost:3306/database_name.

您还可以使用此URL创建一个新的数据库

you can also create a fresh database using this URL

jdbc:mysql://localhost:3306/database_name?createDatabaseIfNotExist=true

createDatabaseIfNotExist 这个关键字在您的系统中创建一个全新的数据库.如果数据库不存在.如果存在,请跳过执行.

createDatabaseIfNotExist this keyword create a fresh new database in your system. If the database does not exist. if exist, skip executing.

如何使用Liquibase创建数据库

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

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