After restarting the docker container, an error was found: Error: failed to connect to database: Unknown database type: mysql #9880

Closed
opened 2025-11-02 08:52:08 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @sanduo-656 on GitHub (Nov 23, 2022).

Description

I use docker-compose to run gitea, and I have done many tests. After successfully installing the gitea software, after modifying the app.ini configuration file and restarting the container, the following error will appear.
My gitea image tags are gitea:latest and gitea:dev. Both images are downloaded from hub.docker.com.
My data software is mysql:8.0.31, obviously there is no problem with the database, and it can be connected through Navicat software.

gitea        | 2022/11/23 18:08:19 routers/init.go:116:GlobalInitInstalled() [I] Git Version: 2.36.3, Wire Protocol Version 2 Enabled (home: /data/gitea/home)
gitea        | 2022/11/23 18:08:19 routers/init.go:117:GlobalInitInstalled() [I] AppPath: /usr/local/bin/gitea
gitea        | 2022/11/23 18:08:19 routers/init.go:118:GlobalInitInstalled() [I] AppWorkPath: /app/gitea
gitea        | 2022/11/23 18:08:19 routers/init.go:119:GlobalInitInstalled() [I] Custom path: /data/gitea
gitea        | 2022/11/23 18:08:19 routers/init.go:120:GlobalInitInstalled() [I] Log path: /data/gitea/log
gitea        | 2022/11/23 18:08:19 routers/init.go:121:GlobalInitInstalled() [I] Configuration file: /data/gitea/conf/app.ini
gitea        | 2022/11/23 18:08:19 routers/init.go:122:GlobalInitInstalled() [I] Run Mode: Prod
gitea        | 2022/11/23 18:08:19 ...dules/setting/log.go:335:newLogService() [I] Gitea Log Mode: Console(Console:info)
gitea        | 2022/11/23 18:08:19 ...dules/setting/log.go:249:generateNamedLogger() [I] Router Log: Console(console:info)
gitea        | 2022/11/23 18:08:19 ...les/setting/cache.go:76:newCacheService() [I] Cache Service Enabled
gitea        | 2022/11/23 18:08:19 ...les/setting/cache.go:91:newCacheService() [I] Last Commit Cache Service Enabled
gitea        | 2022/11/23 18:08:19 ...s/setting/session.go:73:newSessionService() [I] Session Service Enabled
gitea        | 2022/11/23 18:08:19 ...s/storage/storage.go:176:initAttachments() [I] Initialising Attachment storage with type:
gitea        | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/attachments
gitea        | 2022/11/23 18:08:19 ...s/storage/storage.go:170:initAvatars() [I] Initialising Avatar storage with type:
gitea        | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/avatars
gitea        | 2022/11/23 18:08:19 ...s/storage/storage.go:188:initRepoAvatars() [I] Initialising Repository Avatar storage with type:
gitea        | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/repo-avatars
gitea        | 2022/11/23 18:08:19 ...s/storage/storage.go:182:initLFS() [I] Initialising LFS storage with type:
gitea        | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/git/lfs
gitea        | 2022/11/23 18:08:19 ...s/storage/storage.go:194:initRepoArchives() [I] Initialising Repository Archive storage with type:
gitea        | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/repo-archive
gitea        | 2022/11/23 18:08:19 ...s/storage/storage.go:200:initPackages() [I] Initialising Packages storage with type:
gitea        | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/packages
gitea        | 2022/11/23 18:08:19 routers/init.go:140:GlobalInitInstalled() [I] SQLite3 support is enabled
gitea        | 2022/11/23 18:08:19 routers/common/db.go:20:InitDBEngine() [I] Beginning ORM engine initialization.
gitea        | 2022/11/23 18:08:19 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #1/10...
gitea        | 2022/11/23 18:08:19 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: failed to connect to database: Unknown database type:  mysql
gitea        | 2022/11/23 18:08:19 routers/common/db.go:34:InitDBEngine() [I] Backing off for 3 seconds
gitea        | 2022/11/23 18:08:22 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #2/10...
gitea        | 2022/11/23 18:08:22 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #2/10 failed. Error: failed to connect to database: Unknown database type:  mysql

Gitea Version

gitea:dev

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

Uploading image.png…

Git Version

No response

Operating System

No response

How are you running Gitea?

docker

Database

MySQL

Originally created by @sanduo-656 on GitHub (Nov 23, 2022). ### Description I use docker-compose to run gitea, and I have done many tests. After successfully installing the gitea software, after modifying the app.ini configuration file and restarting the container, the following error will appear. My gitea image tags are gitea:latest and gitea:dev. Both images are downloaded from hub.docker.com. My data software is mysql:8.0.31, obviously there is no problem with the database, and it can be connected through Navicat software. ``` gitea | 2022/11/23 18:08:19 routers/init.go:116:GlobalInitInstalled() [I] Git Version: 2.36.3, Wire Protocol Version 2 Enabled (home: /data/gitea/home) gitea | 2022/11/23 18:08:19 routers/init.go:117:GlobalInitInstalled() [I] AppPath: /usr/local/bin/gitea gitea | 2022/11/23 18:08:19 routers/init.go:118:GlobalInitInstalled() [I] AppWorkPath: /app/gitea gitea | 2022/11/23 18:08:19 routers/init.go:119:GlobalInitInstalled() [I] Custom path: /data/gitea gitea | 2022/11/23 18:08:19 routers/init.go:120:GlobalInitInstalled() [I] Log path: /data/gitea/log gitea | 2022/11/23 18:08:19 routers/init.go:121:GlobalInitInstalled() [I] Configuration file: /data/gitea/conf/app.ini gitea | 2022/11/23 18:08:19 routers/init.go:122:GlobalInitInstalled() [I] Run Mode: Prod gitea | 2022/11/23 18:08:19 ...dules/setting/log.go:335:newLogService() [I] Gitea Log Mode: Console(Console:info) gitea | 2022/11/23 18:08:19 ...dules/setting/log.go:249:generateNamedLogger() [I] Router Log: Console(console:info) gitea | 2022/11/23 18:08:19 ...les/setting/cache.go:76:newCacheService() [I] Cache Service Enabled gitea | 2022/11/23 18:08:19 ...les/setting/cache.go:91:newCacheService() [I] Last Commit Cache Service Enabled gitea | 2022/11/23 18:08:19 ...s/setting/session.go:73:newSessionService() [I] Session Service Enabled gitea | 2022/11/23 18:08:19 ...s/storage/storage.go:176:initAttachments() [I] Initialising Attachment storage with type: gitea | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/attachments gitea | 2022/11/23 18:08:19 ...s/storage/storage.go:170:initAvatars() [I] Initialising Avatar storage with type: gitea | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/avatars gitea | 2022/11/23 18:08:19 ...s/storage/storage.go:188:initRepoAvatars() [I] Initialising Repository Avatar storage with type: gitea | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/repo-avatars gitea | 2022/11/23 18:08:19 ...s/storage/storage.go:182:initLFS() [I] Initialising LFS storage with type: gitea | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/git/lfs gitea | 2022/11/23 18:08:19 ...s/storage/storage.go:194:initRepoArchives() [I] Initialising Repository Archive storage with type: gitea | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/repo-archive gitea | 2022/11/23 18:08:19 ...s/storage/storage.go:200:initPackages() [I] Initialising Packages storage with type: gitea | 2022/11/23 18:08:19 ...les/storage/local.go:46:NewLocalStorage() [I] Creating new Local Storage at /data/gitea/packages gitea | 2022/11/23 18:08:19 routers/init.go:140:GlobalInitInstalled() [I] SQLite3 support is enabled gitea | 2022/11/23 18:08:19 routers/common/db.go:20:InitDBEngine() [I] Beginning ORM engine initialization. gitea | 2022/11/23 18:08:19 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #1/10... gitea | 2022/11/23 18:08:19 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: failed to connect to database: Unknown database type: mysql gitea | 2022/11/23 18:08:19 routers/common/db.go:34:InitDBEngine() [I] Backing off for 3 seconds gitea | 2022/11/23 18:08:22 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #2/10... gitea | 2022/11/23 18:08:22 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #2/10 failed. Error: failed to connect to database: Unknown database type: mysql ``` ### Gitea Version gitea:dev ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots ![Uploading image.png…]() ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? docker ### Database MySQL
GiteaMirror added the type/bug label 2025-11-02 08:52:08 -06:00
Author
Owner

@lunny commented on GitHub (Nov 24, 2022):

It's very wired.

@lunny commented on GitHub (Nov 24, 2022): It's very wired.
Author
Owner

@sanduo-656 commented on GitHub (Nov 24, 2022):

It's very wired.

Yes, I am also puzzled. I tested it on two different devices and the result is still the same. I will post the content of my docker-compose.yml script, you can also try to see if you have the same problem!
192.168.1.51 is my physical host ip address

`version: "3"

networks:
gitea:
external: false
ipam:
config:
- subnet: 172.18.0.0/24

services:
server:
image: gitea/gitea:latest
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- GITEA__database__DB_TYPE=mysql
- GITEA__database__HOST=192.168.1.51:3406
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=gitea
restart: always
networks:
gitea:
ipv4_address: 172.18.0.3
volumes:
- /data/gitea/gitea/data:/data
- /data/gitea/gitea/etc/timezone:/etc/timezone:ro
- /data/gitea/gitea/etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
depends_on:
- db

db:
image: mysql:8.0.31
container_name: mysqlserver
restart: always
environment:
- MYSQL_ROOT_PASSWORD=1234.com
- MYSQL_USER=gitea
- MYSQL_PASSWORD=gitea
- MYSQL_DATABASE=gitea
networks:
gitea:
ipv4_address: 172.18.0.2
ports:
- "3406:3306"
volumes:
- /data/gitea/mysql/data:/var/lib/mysql
- /data/gitea/mysql/logs:/var/log/mysql
`

@sanduo-656 commented on GitHub (Nov 24, 2022): > It's very wired. Yes, I am also puzzled. I tested it on two different devices and the result is still the same. I will post the content of my docker-compose.yml script, you can also try to see if you have the same problem! 192.168.1.51 is my physical host ip address `version: "3" networks: gitea: external: false ipam: config: - subnet: 172.18.0.0/24 services: server: image: gitea/gitea:latest container_name: gitea environment: - USER_UID=1000 - USER_GID=1000 - GITEA__database__DB_TYPE=mysql - GITEA__database__HOST=192.168.1.51:3406 - GITEA__database__NAME=gitea - GITEA__database__USER=gitea - GITEA__database__PASSWD=gitea restart: always networks: gitea: ipv4_address: 172.18.0.3 volumes: - /data/gitea/gitea/data:/data - /data/gitea/gitea/etc/timezone:/etc/timezone:ro - /data/gitea/gitea/etc/localtime:/etc/localtime:ro ports: - "3000:3000" - "222:22" depends_on: - db db: image: mysql:8.0.31 container_name: mysqlserver restart: always environment: - MYSQL_ROOT_PASSWORD=1234.com - MYSQL_USER=gitea - MYSQL_PASSWORD=gitea - MYSQL_DATABASE=gitea networks: gitea: ipv4_address: 172.18.0.2 ports: - "3406:3306" volumes: - /data/gitea/mysql/data:/var/lib/mysql - /data/gitea/mysql/logs:/var/log/mysql `
Author
Owner

@wxiaoguang commented on GitHub (Nov 26, 2022):

You have extra space in the database type. Check your config carefully.

image

@wxiaoguang commented on GitHub (Nov 26, 2022): You have extra space in the database type. Check your config carefully. ![image](https://user-images.githubusercontent.com/2114189/204079503-c3d95f61-0e7c-41de-be7f-6945890886df.png)
Author
Owner

@zeripath commented on GitHub (Nov 26, 2022):

UGH that's horrible - lets trim that.

@zeripath commented on GitHub (Nov 26, 2022): UGH that's horrible - lets trim that.
Author
Owner

@zeripath commented on GitHub (Nov 26, 2022):

although I guess the problem is that nothing else is trimmed in reading the settings files...

@zeripath commented on GitHub (Nov 26, 2022): although I guess the problem is that nothing else is trimmed in reading the settings files...
Author
Owner

@wxiaoguang commented on GitHub (Nov 26, 2022):

although I guess the problem is that nothing else is trimmed in reading the settings files...

INI reader will always do default trimming.

But if a user writes env A=" B" or ini A=" B", the spaces won't be trimmed.

@wxiaoguang commented on GitHub (Nov 26, 2022): > although I guess the problem is that nothing else is trimmed in reading the settings files... INI reader will always do default trimming. But if a user writes env `A=" B"` or ini `A=" B"`, the spaces won't be trimmed.
Author
Owner

@sanduo-656 commented on GitHub (Nov 26, 2022):

You have extra space in the database type. Check your config carefully.

image

You mean mysql before the box? My problem occurs with a failure that occurs after a restart of a normally running container.

@sanduo-656 commented on GitHub (Nov 26, 2022): > You have extra space in the database type. Check your config carefully. > > ![image](https://user-images.githubusercontent.com/2114189/204079503-c3d95f61-0e7c-41de-be7f-6945890886df.png) You mean mysql before the box? My problem occurs with a failure that occurs after a restart of a normally running container.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9880