nacos-mysql.sql内容
时间: 2023-07-09 22:14:45 浏览: 104
nacos-mysql.sql 是 Nacos 配置中心使用的 MySQL 数据库初始化脚本,它包含了创建 Nacos 配置中心所需的数据库、表和索引等 SQL 语句。具体内容如下:
```
-- 创建数据库
CREATE DATABASE IF NOT EXISTS `nacos_config` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
-- 切换到 nacos_config 数据库
USE `nacos_config`;
-- 创建数据表:config_info
CREATE TABLE `config_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`data_id` varchar(256) COLLATE utf8_bin NOT NULL DEFAULT '',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`content` longtext COLLATE utf8_bin NOT NULL,
`md5` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_config_info_data_id_group_id` (`data_id`,`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- 创建数据表:config_info_aggr
CREATE TABLE `config_info_aggr` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`data_id` varchar(256) COLLATE utf8_bin NOT NULL DEFAULT '',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`content` longtext COLLATE utf8_bin NOT NULL,
`md5` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_config_info_aggr_data_id_group_id` (`data_id`,`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- 创建数据表:config_history
CREATE TABLE `config_history` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`data_id` varchar(256) COLLATE utf8_bin NOT NULL DEFAULT '',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`content` longtext COLLATE utf8_bin NOT NULL,
`md5` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_config_history_gmt_create` (`gmt_create`),
KEY `idx_config_history_data_id` (`data_id`),
KEY `idx_config_history_group_id` (`group_id`),
KEY `idx_config_history_md5` (`md5`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- 创建数据表:config_tags
CREATE TABLE `config_tags` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`data_id` varchar(256) COLLATE utf8_bin NOT NULL DEFAULT '',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`tag_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_config_tags_gmt_create` (`gmt_create`),
KEY `idx_config_tags_data_id` (`data_id`),
KEY `idx_config_tags_group_id` (`group_id`),
KEY `idx_config_tags_tag_id` (`tag_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
```
以上是 nacos-mysql.sql 的内容,执行这些 SQL 语句可以初始化 Nacos 配置中心所需的数据库表结构。
阅读全文