TeamCity
 
You are viewing the documentation for an earlier version of TeamCity.

Migrating to MySQL database

Last modified: 20 April 2023

Migrating to MySQL database 



We strongly recommend to use MySQL as backend TeamCity database in production environment. There are two ways to switch to MySQL:

  • Quick method preserves only build configurations but not the historical data and users

  • Full method preserves all historical data, build messages and user accounts

Quick migration:



  1. Install and setup MySQL see Installation

  2. Cleanup system folder: you must remove old messages and artifacts folders from .BuildServer/system; you may delete old hsql db - buildserver.* files

  3. Start TeamCity server

Full Migration:



  1. Shut TeamCity server down.

  2. Create a backup copy of TeamCity data folder used by the server

  3. Download MySQL JDBC driver from: http://dev.mysql.com/downloads/connector/j/

  4. Place MySQL driver into the TeamCity WEB-INF/lib folder. Further instructions assume the driver is named mysql-connector-java-5.0.5-bin.jar

  5. Run export/import tool (see below)

  6. Upon successful completion of database migration, a database.properties file will be created. You can move this file to your <TeamCity Data Directory> /config folder

  7. Please open .BuildServer\system\version.dat and ensure that version.com.mysql.jdbc.Driver has same value as version.org.hsqldb.jdbcDriver

  8. Start TeamCity server

Please note that target database must be empty (contain NO tables).

To start export/import tool use the following commands (they should be invoked from the the TeamCity WEB-INF/lib folder):

  • For Windows:

SET CP=server.jar;openapi.jar;server-openapi.jar;mysql-connector-java-5.0.5-bin.jar;hsqldb.jar;dbunit-2.2.jar java -Xmx512m -cp %CP% jetbrains.buildServer.serverSide.HSQL2MySQL <arguments>

  • For Unix:

export CP=server.jar:openapi.jar:server-openapi.jar:mysql-connector-java-5.0.5-bin.jar:hsqldb.jar:dbunit-2.2.jar java -Xmx512m -cp $CP jetbrains.buildServer.serverSide.HSQL2MySQL <arguments>

Depending on the location of your TeamCity data path there are three different sets of arguments for export/import tool:

  • For the default location of Basic Concepts (i.e. $HOME/.BuildServer): {{<target database URL> <target database user> <user password> {}}}

  • For the non default location of Basic Concepts: {{<path to TeamCity data directory> <target database URL> <target database user> <user password> {}}}

  • For the standalone HSQLDB database: {{<HSQL database URL> <HSQLDB user> <HSQLDB password> <target database URL> <target database user> <user password> {}}}

>cd TC\WEB-INF\lib >SET CP=server.jar;openapi.jar;mysql-connector-java-5.0.6-bin.jar;hsqldb.jar;dbunit-2.2.jar >java -Xmx512m -cp %CP% jetbrains.buildServer.serverSide.HSQL2MySQL \ jdbc:mysql://localhost/buildserver root root Thu Apr 05 12:45:58 MSD 2007 .BuildServer path: C:\Documents and Settings\user\.BuildServer Thu Apr 05 12:45:58 MSD 2007 Connectiong to source database \ jdbc:hsqldb:file:C:\Documents and Settings\user\.BuildServer\system\buildserver Thu Apr 05 12:46:03 MSD 2007 Connectiong to target database jdbc:mysql://localhost/buildserver Thu Apr 05 12:46:03 MSD 2007 Initializing schema... TABLES to be converted: (29) [agent, agent_sources_version, ....] Thu Apr 05 12:46:09 MSD 2007 Exporting data to C:\TEMP\TC-export56020 Thu Apr 05 12:46:10 MSD 2007 Importing data from C:\TEMP\TC-export56019 Thu Apr 05 12:46:13 MSD 2007 Exporting database.properties Thu Apr 05 12:46:13 MSD 2007 Done.

Additional information:



  • MySQL JDBC url format: jdbc:mysql://<host>[:<port>]/<database name> more info

  • If you encounter "out of memory" errors try to increase number in -Xmx512m parameter. On 32 bit platform maximum is about 1300 megabytes.