Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 MySQL 5.7 启动报错:Error 1170: BLOB/TEXT column 'key' used in key specification without a key length #23

Closed
lmuiotctf opened this issue Apr 26, 2023 · 29 comments
Labels
bug Something isn't working

Comments

@lmuiotctf
Copy link

怎么PR给你

@songquanpeng songquanpeng changed the title 我PR一个从根目录读取.env文件 支持从工作根目录读取 .env 文件 Apr 26, 2023
@songquanpeng
Copy link
Owner

大家一般用 Docker 来部署,这个我感觉意义不大哈。

@songquanpeng songquanpeng added question Further information is requested enhancement New feature or request and removed question Further information is requested labels Apr 26, 2023
@lmuiotctf
Copy link
Author

只有我用GO部署嘛 哈哈哈

@songquanpeng
Copy link
Owner

Docker 的话主要是更新很方便,如果用 MySQL & Redis 的话,应该配合 Docker Compose 使用。

而 One API 里面需要设置环境变量的也主要就这两个。

@lmuiotctf
Copy link
Author

目前还不是采用MYSQL吧,看了下是SQLite,有计划把微信公众号合并到这里嘛

@songquanpeng
Copy link
Owner

songquanpeng commented Apr 26, 2023 via email

@lmuiotctf
Copy link
Author

这样的话,是不是少了个sql库,可以直接改成mysql

@songquanpeng
Copy link
Owner

配置环境变量 SQL_DSN 就好,MySQL 是原本就支持的,不过未测试可能会有问题。

本项目基于我的模板项目 gin-template,对于 MySQL 的支持也是继承于该项目。

@lmuiotctf
Copy link
Author

确实,启动之后可能是我的库5.7版本过低。报错

@songquanpeng
Copy link
Owner

可以看一下报错信息吗?

@songquanpeng songquanpeng changed the title 支持从工作根目录读取 .env 文件 使用 MySQL 5.7 启用报错 Apr 26, 2023
@songquanpeng songquanpeng added bug Something isn't working and removed enhancement New feature or request labels Apr 26, 2023
@songquanpeng songquanpeng changed the title 使用 MySQL 5.7 启用报错 使用 MySQL 5.7 启动报错 Apr 26, 2023
@lmuiotctf
Copy link
Author

CREATE TABLE tokens (id bigint AUTO_INCREMENT,user_id bigint,key longtext,status bigint DEFAULT 1,name varchar(191),created_time bigint,accessed_time bigint,expired_time bigint DEFAULT -1,remain_times bigint DEFAULT 0,unlimited_times boolean DEFAULT false,PRIMARY KEY (id),INDEX idx_tokens_name (name),UNIQUE INDEX idx_tokens_key (key))
[FATAL] 2023/04/26 - 14:19:54 | [Error 1170: BLOB/TEXT column 'key' used in key specification without a key length]

@songquanpeng
Copy link
Owner

Okay,有时间处理一下这个问题。

@lmuiotctf
Copy link
Author

辛苦

@songquanpeng
Copy link
Owner

已修复,版本 v0.1.6-alpha 已推送,期待反馈。

@songquanpeng songquanpeng changed the title 使用 MySQL 5.7 启动报错 使用 MySQL 5.7 启动报错:Error 1170: BLOB/TEXT column 'key' used in key specification without a key length Apr 27, 2023
@lmuiotctf
Copy link
Author

MySQL测试下已经🆗
image

@lmuiotctf
Copy link
Author

lmuiotctf commented Apr 27, 2023

目前问题:渠道和令牌表id没有自增,会报错,记得改下

@songquanpeng
Copy link
Owner

可以看一下报错信息吗?我现在没有 MySQL 环境可以测试。

@songquanpeng songquanpeng reopened this Apr 27, 2023
@lmuiotctf
Copy link
Author

我刚刚改了这两张表就可以,报错是:id没有值,没有自动递增
image

@songquanpeng
Copy link
Owner

我记得另一个项目里是可以自动递增的,不然主键冲突肯定会报错的。

我回去之后有了 MySQL 环境后再测试一下。

@lmuiotctf
Copy link
Author

目前普通用户可以自己创建令牌,但是超级管理员应该可以查看到普通用户创建的令牌。(目前管理员仅能看到自己)
逻辑应该是普通用户仅有创建令牌的功能,但是没有权限进行设置次数和到期时间,这两个应该交给管理员来控制

@songquanpeng
Copy link
Owner

普通用户没法设置次数的,需要使用兑换码,而兑换码只能管理员生成。

到期时间这个,感觉放开给用户无所谓。

@lmuiotctf
Copy link
Author

不好意思刚刚页面没有刷新,应该卡bug了(刚刚普通用户居然可以输入次数,现在不可以了)
image

@songquanpeng
Copy link
Owner

#9

@songquanpeng
Copy link
Owner

应该是你刚刚登录了管理员账户,这个就算他能输入后端也不会给改的。

@lmuiotctf
Copy link
Author

超级管理员应该可以查看到普通用户创建的令牌。(目前管理员仅能看到自己)
我觉得这点可以加上,超管支持查看所有的令牌

@songquanpeng
Copy link
Owner

感觉管理员管理用户的令牌意义不大哈,如果用户有问题可以直接封禁用户的。

不过我突然意识到令牌校验时并没有检查用户的状态,导致用户被禁用后令牌还能用。

@lmuiotctf
Copy link
Author

这个可以进行优化下

@songquanpeng
Copy link
Owner

Okay,不过管理员管理用户令牌这个,应该单独开一个 issue,和当前 issue 主题关系不大不方便归档哈

@songquanpeng
Copy link
Owner

目前问题:渠道和令牌表id没有自增,会报错,记得改下

MySQL 8.0.27 未能复现。

@songquanpeng
Copy link
Owner

如果新版本依旧有问题,欢迎重开 issue。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants