Migrating to MySQL database
Last modified: 20 April 2023Migrating 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:
Install and setup MySQL see Installation
Cleanup system folder: you must remove old messages and artifacts folders from .BuildServer/system; you may delete old hsql db - buildserver.* files
Start TeamCity server
Full Migration:
Shut TeamCity server down.
Create a backup copy of TeamCity data folder used by the server
Download MySQL JDBC driver from: http://dev.mysql.com/downloads/connector/j/
Place MySQL driver into the TeamCity
WEB-INF/lib
folder. Further instructions assume the driver is namedmysql-connector-java-5.0.5-bin.jar
Run export/import tool (see below)
Upon successful completion of database migration, a
database.properties
file will be created. You can move this file to your<TeamCity Data Directory> /config
folderPlease open
.BuildServer\system\version.dat
and ensure thatversion.com.mysql.jdbc.Driver
has same value asversion.org.hsqldb.jdbcDriver
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.
Thanks for your feedback!