ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## **2) 数据库创建** - 表`RouteData`: 保存了所有mod路由信息. | 字段 | 数据类型 | 是否可以为空 | 主键 | 默认 | 附加 | 说明 | | ---------- | ---------------- | ------------ | ---- | ---- | ------ | ------------ | | id | int(10) unsigned | No | 是 | NULL | 自增长 | 该条数据ID | | modid | int(10) unsigned | No | | NULL | | 模块ID | | cmdid | int(10) unsigned | No | | NULL | | 指令ID | | serverip | int(10) unsigned | No | | NULL | | 服务器IP地址 | | serverport | int(10) unsigned | No | | NULL | | 服务器端口 | - 表`RouteVersion`: 当前`RouteData`路由版本号,每次管理端修改某mod的路由,`RouteVersion`表中的版本号都被更新为当前时间戳 | 字段 | 数据类型 | 是否可以为空 | 主键 | 默认 | 附加 | | ------- | ---------------- | ------------ | ---- | ---- | ------ | | id | int(10) unsigned | No | 是 | NULL | 自增长 | | version | int(10) unsigned | No | | NULL | | - 表`RouteChange`: 每次管理端修改某mod的路由,会记录本次对哪个mod进行修改(增、删、改),以便指示最新的`RouteData`路由有哪些mod变更了。 | 字段 | 数据类型 | 是否可以为空 | 主键 | 默认 | 附加 | | ------- | ------------------- | ------------ | ---- | ---- | ------ | | id | int(10) unsigned | No | 是 | NULL | 自增长 | | modid | int(10) unsigned | No | | NULL | | | cmdid | int(10) unsigned | No | | NULL | | | version | bigint(20) unsigned | No | | NULL | | 相关创建表格的sql语句如下`lars_dns.sql` ```sql DROP DATABASE if exists lars_dns; CREATE DATABASE lars_dns; USE lars_dns; DROP TABLE IF EXISTS `RouteData`; CREATE TABLE `RouteData` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `modid` int(10) unsigned NOT NULL, `cmdid` int(10) unsigned NOT NULL, `serverip` int(10) unsigned NOT NULL, `serverport` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=116064 DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `RouteVersion`; CREATE TABLE RouteVersion ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `version` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) ); INSERT INTO RouteVersion(version) VALUES(0); DROP TABLE IF EXISTS `RouteChange`; CREATE TABLE RouteChange ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `modid` int(10) unsigned NOT NULL, `cmdid` int(10) unsigned NOT NULL, `version` bigint(20) unsigned NOT NULL, PRIMARY KEY (`id`) ); ``` ​ 我们创建一个基础目录`Lars/base`来存放一些公共的工具和资源. cd到`Lars/base`, 我们`mkdir sql`, 然后将`lars_dns.sql`拷贝到`sql/`文件夹下。 然后执行创建表格 ```sql $mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 18 Server version: 5.7.27-0ubuntu0.18.04.1 (Ubuntu) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> \. lars_dns.sql Query OK, 0 rows affected, 1 warning (0.01 sec) Query OK, 1 row affected (0.00 sec) Database changed Query OK, 0 rows affected, 1 warning (0.00 sec) Query OK, 0 rows affected (0.08 sec) Query OK, 0 rows affected, 1 warning (0.01 sec) Query OK, 0 rows affected (0.06 sec) Query OK, 1 row affected (0.01 sec) Query OK, 0 rows affected, 1 warning (0.01 sec) Query OK, 0 rows affected (0.13 sec) ``` --- ### 关于作者: 作者:`Aceld(刘丹冰)` mail: [danbing.at@gmail.com](mailto:danbing.at@gmail.com) github: [https://github.com/aceld](https://github.com/aceld) 原创书籍: [https://www.kancloud.cn/@aceld](https://www.kancloud.cn/@aceld) ![](https://img.kancloud.cn/b0/d1/b0d11a21ba62e96aef1c11d5bfff2cf8_227x227.jpg) >**原创声明:未经作者允许请勿转载, 如果转载请注明出处**