MYSQL: Database error on installation #518

Closed
opened 2025-11-02 03:26:27 -06:00 by GiteaMirror · 16 comments
Owner

Originally created by @pree on GitHub (Mar 16, 2017).

Originally assigned to: @lunny on GitHub.

Description

Getting the following Database Error when installing on a empty Database.
Database setting is not correct: Error 1170: BLOB/TEXT column 'key_id' used in key specification without a key length

MySQL-Server Version: 10.0.30-MariaDB-0+deb8u1

Screenshots

image

Originally created by @pree on GitHub (Mar 16, 2017). Originally assigned to: @lunny on GitHub. - Gitea version (or commit ref): 447c9b428f4cf50174ef7f3fbea56b5405f6bbf8 - Git version: 2.1.4 - Operating system: Debian - Database (use `[x]`): - [ ] PostgreSQL - [X] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [X] Not relevant - Log gist: https://gist.github.com/Schizopriest/d6ccdad0170812dfb5bc510f8c283d76 ## Description Getting the following Database Error when installing on a empty Database. `Database setting is not correct: Error 1170: BLOB/TEXT column 'key_id' used in key specification without a key length` MySQL-Server Version: `10.0.30-MariaDB-0+deb8u1` ## Screenshots ![image](https://cloud.githubusercontent.com/assets/9799276/23990790/65827e74-0a37-11e7-9733-adf97f278b9f.png)
GiteaMirror added the type/bug label 2025-11-02 03:26:27 -06:00
Author
Owner

@lunny commented on GitHub (Mar 16, 2017):

We haven't tested on Mariadb although it should be the same as MySQL.

@lunny commented on GitHub (Mar 16, 2017): We haven't tested on Mariadb although it should be the same as MySQL.
Author
Owner

@cez81 commented on GitHub (Mar 16, 2017):

Just tested this on a fresh install of prebuilt 1.1.0 with 10.0.29-MariaDB-0ubuntu0.16.04.1 on Ubuntu 16.04. InnoDB as engine.
It installs without any errors for me. Been using MariaDB on my production setup without any problems.

Edit:: But 1.1.0+38-gf1d2f16 fails...

@cez81 commented on GitHub (Mar 16, 2017): Just tested this on a fresh install of prebuilt 1.1.0 with 10.0.29-MariaDB-0ubuntu0.16.04.1 on Ubuntu 16.04. InnoDB as engine. It installs without any errors for me. Been using MariaDB on my production setup without any problems. Edit:: But 1.1.0+38-gf1d2f16 fails...
Author
Owner

@Diablofan commented on GitHub (Mar 16, 2017):

I can confirm this happening with MariaDB as well. Tried using the docker image 81f5b797cd07 (latest as of March 16 at 5:41 PM EST), and I was getting this error when trying a fresh install of gitea. Trying with the image tagged 1.1.0 works just fine.

@Diablofan commented on GitHub (Mar 16, 2017): I can confirm this happening with MariaDB as well. Tried using the docker image 81f5b797cd07 (latest as of March 16 at 5:41 PM EST), and I was getting this error when trying a fresh install of gitea. Trying with the image tagged 1.1.0 works just fine.
Author
Owner

@lunny commented on GitHub (Mar 17, 2017):

Oh, maybe it's effected by GPG PR. Let me check.

@lunny commented on GitHub (Mar 17, 2017): Oh, maybe it's effected by GPG PR. Let me check.
Author
Owner

@lunny commented on GitHub (Mar 17, 2017):

This is the bug here. A text column should not be a index. https://github.com/go-gitea/gitea/blob/master/models/gpg_key.go#L23 @sapk what's the max length of a key_id?

@lunny commented on GitHub (Mar 17, 2017): This is the bug here. A `text` column should not be a `index`. https://github.com/go-gitea/gitea/blob/master/models/gpg_key.go#L23 @sapk what's the max length of a `key_id`?
Author
Owner

@sapk commented on GitHub (Mar 17, 2017):

From https://tools.ietf.org/html/rfc4880#section-12.2 "The Key ID is the
low-order 64 bits of the fingerprint." So in hex 64/4 = 16 char

@sapk commented on GitHub (Mar 17, 2017): From https://tools.ietf.org/html/rfc4880#section-12.2 "The Key ID is the low-order 64 bits of the fingerprint." So in hex 64/4 = 16 char
Author
Owner

@sapk commented on GitHub (Mar 17, 2017):

and in fact it's not even usefull to be a index since. I don't use the keyid to find key.

@sapk commented on GitHub (Mar 17, 2017): and in fact it's not even usefull to be a index since. I don't use the keyid to find key.
Author
Owner

@gzsombor commented on GitHub (Mar 17, 2017):

Changing from "INDEX TEXT NOT NULL" to "TEXT NOT NULL" solves the problem - at least for me.

@gzsombor commented on GitHub (Mar 17, 2017): Changing from "INDEX TEXT NOT NULL" to "TEXT NOT NULL" solves the problem - at least for me.
Author
Owner

@lunny commented on GitHub (Mar 17, 2017):

@sapk so maybe we change the tag from INDEX TEXT NOT NULL to CHAR(16) NOT NULL to resolve this?

@lunny commented on GitHub (Mar 17, 2017): @sapk so maybe we change the tag from `INDEX TEXT NOT NULL` to `CHAR(16) NOT NULL` to resolve this?
Author
Owner

@sapk commented on GitHub (Mar 17, 2017):

it should but I can't test right now.

@sapk commented on GitHub (Mar 17, 2017): it should but I can't test right now.
Author
Owner

@lunny commented on GitHub (Mar 17, 2017):

I will send a PR to fix this.

@lunny commented on GitHub (Mar 17, 2017): I will send a PR to fix this.
Author
Owner

@sapk commented on GitHub (Mar 17, 2017):

In fact we could even use a uint64 ?

@sapk commented on GitHub (Mar 17, 2017): In fact we could even use a uint64 ?
Author
Owner

@sapk commented on GitHub (Mar 17, 2017):

I have found maybe a optimization for validating more "quickly" since keyid is in signature but not I will have to test it a lot. So repassing #1150 in WIP

@sapk commented on GitHub (Mar 17, 2017): I have found maybe a optimization for validating more "quickly" since keyid is in signature but not I will have to test it a lot. So repassing #1150 in WIP
Author
Owner

@sapk commented on GitHub (Mar 17, 2017):

I use string because I use it as a string but the value is a uint64 even for primaryId. @lunny you can PR the change proposed CHAR(16) NOT NULL I will test it more of we can optimize DB for validation in #1150

@sapk commented on GitHub (Mar 17, 2017): I use string because I use it as a string but the value is a uint64 even for primaryId. @lunny you can PR the change proposed CHAR(16) NOT NULL I will test it more of we can optimize DB for validation in #1150
Author
Owner

@lunny commented on GitHub (Mar 17, 2017):

OK

@lunny commented on GitHub (Mar 17, 2017): OK
Author
Owner

@sapk commented on GitHub (Mar 17, 2017):

To be more simple it will stay in string format for DB since it will limit format at display but I will use https://github.com/golang/crypto/blob/master/openpgp/packet/public_key.go#L705 the same func to transform uint64 of the keyid store in sign to search only for the good key and not pass over each key of user.

@sapk commented on GitHub (Mar 17, 2017): To be more simple it will stay in string format for DB since it will limit format at display but I will use https://github.com/golang/crypto/blob/master/openpgp/packet/public_key.go#L705 the same func to transform uint64 of the keyid store in sign to search only for the good key and not pass over each key of user.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#518