TeamCity 8.0 Help

Setting up an External Database

TeamCity stores build history, users, build results and some run time data in an SQL database. See also description of what is stored where on Manual Backup and Restore page.

This page covers external database setup for the first use with TeamCity. If you evaluated TeamCity with internal database and want to preserve the data while switching to an external database, please refer to Migrating to an External Database.

By default, TeamCity runs using an internal database based on the HSQLDB database engine. The internal database suits evaluation purposes only; it works out of the box and requires no additional setup. However, we strongly recommend using an external database as a back-end TeamCity database in a production environment. An external database is usually more reliable and provides better performance.

The internal database may crash and lose all your data (e.g. on out of disk space condition). Also, internal database can become extremely slow on large data sets (say, database storage files over 200Mb). Please also note that our support does not cover any performance or database data loss issues if you are using the internal database.

In short, do not EVER use internal HSQLDB database for production TeamCity instances.

The database connection settings are configured in < TEAMCITY_DATA_DIR\config\database.properties file. The file is a Java properties file. If the file is not present, TeamCity automatically uses internal database.

Since TeamCity 8.1, you can configure the database to be used on the TeamCity start: all you need to do is select the type of the database and specify database connection settings. You may also need to download the JDBC driver for your database.

The information below provides instruction on manual configuration of the external database to be used by TeamCity.

Selecting External Database Engine

TeamCity supports MySQL, PostgreSQL, Oracle and MS SQL databases. As a general rule you should use the database that better suits your environment and that you can maintain/configure better in your organization.

While we strive to make sure TeamCity functions equally well under all of the supported databases, issues can surface in some of them under high TeamCity-generated load.

General Steps

  1. If you already ran TeamCity but do not want to preserve any data, delete TeamCity Data Directory.

  2. Run TeamCity with the default settings to create the <TeamCity Data Directory>.

  3. Shutdown the TeamCity server.

  4. Perform database-specific steps described below.

  5. Start the server.

Database Configuration Properties

The database connection settings are configured in TEAMCITY_DATA_DIR\config\database.properties file. If the file is not present, TeamCity automatically uses internal database.

TeamCity uses Apache DBCP for database connection pooling. Please refer to http://commons.apache.org/dbcp/configuration.html for detailed description of configuration properties. Example configurations for each of supported databases are provided in the sections below.

Database Driver Installation

Due to licensing terms, TeamCity does not bundle driver jars for external databases. You will need to download the Java JDBC driver and put the appropriate .jar files (see driver-specific sections below) from it into < TEAMCITY_DATA_DIR/lib/jdbc directory (create it if necessary). Please note that the .jar files should be compiled for the Java version not greater then that used for running TeamCity version, otherwise you might see "Unsupported major.minor version" errors related to the database driver classes.

MySQL

Supported Platforms and Environments

On MySQL server side

Recommended database server settings:

The user in MySQL that will be used by TeamCity must be granted all permissions on the TeamCity database.

On TeamCity server side

Installation:

  1. Download the MySQL JDBC driver from http://dev.mysql.com/downloads/connector/j/. If the MySQL server version is 5.5 or newer, the JDBC driver version should be 5.1.23 or newer.

  2. Place mysql-connector-java- * -bin.jar from the downloaded archive into the < TEAMCITY_DATA_DIR/lib/jdbc.

  3. Create an empty database for TeamCity in MySQL and grant permissions to modify this database to a user from which TeamCity will work with this database. For this you can execute the following SQL commands from MySQL console: create database <database name> default charset utf8; grant all privileges on <database name>.* to <user>@localhost identified by '<password>';

  4. In the TEAMCITY_DATA_DIR/config folder rename database.mysql.properties.dist file to database.properties and specify the required settings in this file: connectionUrl=jdbc:mysql://<host>/<database name> connectionProperties.user=<user> connectionProperties.password=<password>

PostgreSQL

Supported Platforms and Environments

On PostgreSQL server side

  1. Create an empty database for TeamCity in PostgreSQL.

    • Make sure to set up the database to use UTF8.

    • Grant permissions to modify this database to a user which TeamCity will use to work with this database.

On TeamCity server side

  1. Check you JRE version to determine which JDBC driver is required. If you are using JRE 1.6, you need the JDBC4 version. For 1.7 or 1.8, use the JDBC41 version.

  2. Download the required PostgreSQL JDBC driver and place it into the < TEAMCITY_DATA_DIR/lib/jdbc.

  3. In TEAMCITY_DATA_DIR/config rename database.postgresql.properties.dist file to database.properties and specify the required settings in this file: connectionUrl=jdbc:postgresql://<host>/<database name> connectionProperties.user=<user> connectionProperties.password=<password>

Oracle

Supported Platforms and Environments

On Oracle server side

  1. Create an Oracle user account/schema for TeamCity.

    • Make sure to set up the database to use UTF8

    • Grant the CREATE SESSION, CREATE TABLE, EXECUTE ON SYS.DBMS_LOCK permissions to a user which TeamCity will use to work with this database. TeamCity, on the first connect, creates all necessary tables and indices in the user's schema. (Note: TeamCity never attempts to access other schemas even if they are accessible)

On TeamCity server side

  1. Get the Oracle JDBC driver. Supported driver versions are 10.2.0.1.0 and higher. Place the following files:

    • ojdbc6.jar

    • orai18n.jar (can be omitted if missing in the driver version) into the < TEAMCITY_DATA_DIR/lib/jdbc directory.

      It is strongly recommended to locate the driver in your Oracle server installation. Contact your DBA for the files if required. Alternatively, download the Oracle JDBC driver from the Oracle web site. Make sure the driver version is compatible with your Oracle server.

  2. In the TEAMCITY_DATA_DIR/config folder rename database.oracle.properties.dist file to database.properties and specify the required settings in this file: connectionUrl=jdbc:oracle:thin:@//<host>:1521:<servicename> connectionProperties.user=<user> connectionProperties.password=<password>

Microsoft SQL Server

Supported Platforms and Environments

On MS SQL server side

  1. Create a new database. Using case sensitive collation (collation name ending with '_CS_AS') is recommended and is mandatory for the certain functionality (like using non-Windows build agents).

  2. Create TeamCity user and ensure that this user is the owner of the database (grant the user dbo rights). This requirement is necessary because the user needs to have ability to modify the database schema. If you're going to use SSL connections, ensure that the version of MS SQL server and the version of java (on the TeamCity side) are compatible. We recommend using the latest update of SQL server:

    • SQL Server 2012 - all versions

    • SQL Server 2008R2 - Service Pack 2 or Service Pack 1 cumulative update 6

    • SQL Server 2008 - Service Pack 3 cumulative update 4

    • SQL Server 2005 - only with JDK 6 update 27 or lower on the TeamCity side See details on compatibility issues.

  3. Allocate sufficient transaction log space. The requirements vary depending on how intensively the server will be used. It's recommended to setup not less then 1Gb.

On TeamCity server side

You can use either native (recommended) or jtds one.

Native driver

  1. Download the MS sqljdbc package from the Microsoft Download Center and unpack it. Let us assume the directory where you've unpacked the package into is called sqljdbc_home.

  2. Copy the sqljdbc4.jar from the just downloaded package into the /lib/jdbc directory.

  3. In the TEAMCITY_DATA_DIR/config folder rename database.mssql.properties.dist file to database.properties file and specify the following required settings in this file: connectionUrl=jdbc:sqlserver://<host>:1433;databaseName=<database name> connectionProperties.user=<user> connectionProperties.password=<password>

If you use named instance you can specify the instance name in the connection URL, like the following:

connectionUrl=jdbc:sqlserver://<host>\\<instance_name>:1433;databaseName=<database_name> ...

If you prefer to use MS SQL integrated security (Windows authentication) or if you receive "This driver is not configured for integrated authentication" Common Problems, follow the additional steps:

  1. Ensure that your Java bitness is the same as Windows bitness (in other words, Installing and Configuring the TeamCity Server with 64-bit Windows and 32-bit Java with 32-bit Windows).

  2. Copy the sqljdbc_home/enu/auth/x86/sqljdbc_auth.dll (in case of 32-bit system) or sqljdbc_home/enu/auth/x64/sqljdbc_auth.dll (in case of 64-bit system) into your Windows/system32 directory (or another directory denoted in %PATH%). Ensure that there are no other sqljdbc_auth.dll files in your system).

  3. In the <TeamCity data directory>/config folder create file database.properties and specify the connection URL (with no user names or passwords) in this file: connectionUrl=jdbc:sqlserver://<host>:1433;databaseName=<database name>;integratedSecurity=true

More details about setup integrated security for MS SQL native jdbc driver can be found here (for MS SQL 2005) and here (for MS SQL 2008).

JTDS driver

  1. Download the latest 1.2.x jTDS driver distribution file (zip file), unpack the jtds-*.jar driver jar and place it to < TEAMCITY_DATA_DIR/lib/jdbc. (TeamCity is not tested with the driver version 1.3+. It also requires that TeamCity server is run under JDK 1.7+).

  2. In the TEAMCITY_DATA_DIR/config folder rename database.mssql.properties.dist file to database.properties and specify the required settings in this file: connectionUrl=jdbc:jtds:sqlserver://<host>:1433/<database name> connectionProperties.user=<user> connectionProperties.password=<password> connectionProperties.instance=<instance_name>

To use Windows authentication (SSPI) to connect to your SQL Server database, make sure there are no connectionProperties.user and connectionProperties.password properties specified in the database.properties file and also copy jtds-XXX-dist\x86\SSO\ntlmauth.dll file from the JTDS driver package to <TeamCity Home>\bin (when TeamCity is run under x86 JVM), for Installing and Configuring the TeamCity Server use jtds-XXX-dist\x64\SSO\ntlmauth.dll file. Also setup TeamCity server (service or process) to be run under user account that has access to the database.

If you use a named instance, you can specify the instance name by following means:

  • Add the "instance" property into the connection URL, like the following: connectionUrl=jdbc:jtds:sqlserver://<host>:1433/<database name>;instance=sqlexpress

  • Or, specify corresponding property in the database.properties file: connectionProperties.instance=<instance_name>

Last modified: 20 April 2023