Which Database Systems Does Gitea Support? A Complete Guide to RDBMS Configuration
Gitea supports four relational database systems: MySQL/MariaDB, PostgreSQL, Microsoft SQL Server (MSSQL), and SQLite3, with SQLite3 requiring a specific build flag to enable.
The open-source Git service go-gitea/gitea offers flexible database backend options to accommodate different deployment scenarios, from lightweight personal installations to enterprise-scale setups. Understanding which database systems Gitea supports ensures you select the right storage engine for your performance and scalability requirements.
Supported Database Types in Gitea
According to the source code in modules/setting/database.go, Gitea maintains a definitive list of supported relational database engines through the SupportedDatabaseTypes slice and the DatabaseTypeNames map.
The core supported databases include:
- MySQL / MariaDB – Fully supported via the native driver, suitable for production environments requiring high concurrency.
- PostgreSQL – Fully supported, often preferred for its advanced features and strict SQL compliance.
- Microsoft SQL Server (MSSQL) – Fully supported for Windows-centric infrastructure.
- SQLite3 – Available only when Gitea is compiled with the
sqlitebuild flag (EnableSQLite3), intended for lightweight deployments or testing environments.
The SupportedDatabaseTypes slice explicitly enumerates the built-in drivers as ["mysql", "postgres", "mssql"] at lines 18-20. The DatabaseTypeNames map contains an additional entry for sqlite3, which is conditionally enabled based on build-time flags at lines 20-22.
Configuring Your Database Connection in app.ini
Database selection occurs in Gitea's primary configuration file through the DB_TYPE parameter. The following example demonstrates valid configuration options for each supported driver:
[database]
# Choose one of: mysql, postgres, mssql, sqlite3
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = gitea
USER = gitea
PASSWD = secret
# Optional for MySQL/MariaDB
CHARSET_COLLATION = utf8mb4_general_ci
# Example for SQLite3 (only if compiled with SQLite support)
# DB_TYPE = sqlite3
# PATH = /var/lib/gitea/gitea.db
When using SQLite3, the PATH setting specifies the file location for the database, and the binary must be built with SQLite support enabled. For MySQL, PostgreSQL, and MSSQL, Gitea constructs connection strings using the host, port, and credential parameters defined in this configuration section.
How Gitea Detects and Initializes Database Drivers
Gitea's database abstraction layer relies on multiple source files to manage driver detection and initialization:
modules/setting/database.go– Defines supported database types, connection-string helpers, and type-checking methods includingIsMySQL(),IsPostgreSQL(),IsMSSQL(), andIsSQLite3().models/db/engine_init.go– Initializes the XORM engine based on the selected driver fromapp.iniand applies driver-specific optimizations.services/doctor/dbconsistency.go– Performs runtime consistency checks that adapt behavior according to the active database type, such as special handling for PostgreSQL-specific constraints.
These components work together to parse the DB_TYPE configuration value, validate it against the SupportedDatabaseTypes slice, and instantiate the appropriate database driver for the ORM layer.
Summary
- Gitea officially supports MySQL/MariaDB, PostgreSQL, and MSSQL out-of-the-box without requiring special build flags.
- SQLite3 support is optional and requires compiling Gitea with the
sqlitebuild flag, making it suitable only for testing or single-user deployments. - The authoritative list of supported drivers resides in
modules/setting/database.gowithin theSupportedDatabaseTypesslice. - Database configuration occurs in
app.iniusing theDB_TYPEparameter, with driver-specific initialization handled inmodels/db/engine_init.go.
Frequently Asked Questions
Does Gitea support SQLite3 by default?
No. SQLite3 support is not enabled in standard Gitea binaries. You must build Gitea from source with the sqlite build flag (tag) to enable SQLite3 functionality. Pre-built official releases typically exclude SQLite3 support to reduce binary size and dependencies.
Which database is recommended for production Gitea installations?
PostgreSQL or MySQL/MariaDB are recommended for production environments due to their robust concurrency handling, backup utilities, and performance characteristics under heavy Git operation loads. SQLite3 is explicitly discouraged for production multi-user deployments.
Can I migrate Gitea data between different database systems?
Gitea does not provide built-in automated migration tools between database backends. Migrating typically requires exporting data from the source database and importing it into the target, potentially using Gitea's backup/restore utilities or third-party database migration tools. Always backup your data before attempting migration.
Where is the database configuration stored in Gitea?
The database configuration resides in the [database] section of app.ini (or app.ini within the custom configuration path). The DB_TYPE parameter selects the driver, while connection details like HOST, NAME, USER, and PASSWD define the connection parameters for MySQL, PostgreSQL, or MSSQL deployments.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →