Search the JIRA 5.0.x Beta and RCs Documentation:

Index
Downloads (PDF, HTML & XML formats)
Other versions

This documentation relates to JIRA 5.0.x Beta and RCs only.
The latest official version is JIRA 4.4.x
If you are using JIRA 4.4.x either view this page in the JIRA 4.4.x documentation or visit the JIRA 4.4.x documentation home page.
Skip to end of metadata
Go to start of metadata

These instructions will help you connect JIRA to a MySQL 5.x database.

(info) Please Note:

1. Before You Begin

1.1 Are You Migrating JIRA to Another Server?

If you are Migrating JIRA to Another Server, create an export of your data as an XML backup. You will then be able to transfer data from your old database to your new database, as described in Switching databases.

1.2 Shut Down JIRA

1.3 Known Issues with MySQL

If you are using a MySQL database with any of the following:

  • JIRA 3.13 or above,
  • version 5.5.25 or higher of Tomcat 5,
  • version 6.0.13 or higher of Tomcat 6,

you may experience problems with your connections dropping out (see JRA-15731 for details). Please read Surviving Connection Closures for information on the changes required to your application server to address this.

If you experience any other issues with using JIRA and MySQL, please refer to our additional notes for more information.

2. Create and Configure the MySQL Database

  1. Create a database user which JIRA will connect as (e.g. jiradbuser). (tick) Remember this database user name, as it will be used to configure JIRA's connection to this database in subsequent steps.
  2. Create a database for JIRA to store issues in (e.g. jiradb). The database must have a character set of UTF8. Enter the following command from within the MySQL command client:

    (if you want your database to be named jiradb). (tick) Remember this database name, as it will be used to configure JIRA's connection to this database in subsequent steps.

  3. Ensure that the user has permission to connect to the database, and permission to create and populate tables.

3. Copy the MySQL JDBC Driver to Your Application Server (JIRA WAR Only)

(warning) Skipthis step if you installed a 'Recommended' distribution of JIRA, which (unlike JIRA WAR) includes the MySQL JDBC driver.

  1. Download the MySQL Connector/J JDBC driver v5.1
    (warning) A user had reported experiencing problems with the Resin JDBC driver for MySQL. However, the Connector/J driver from MySQL is known to work correctly.
  2. Add the MySQL JDBC driver jar (mysql-connector-java-5.x.x-bin.jar) to the lib/ directory.

4. Configure Your JIRA Server to Connect to Your MySQL Database

There are two ways to configure your JIRA server to connect to your MySQL database:

(info) Please Note:

4.1 Connecting JIRA to MySQL Using the JIRA Configuration Tool

(warning) The JIRA Configuration Tool is not available with JIRA WAR distributions.

To start the JIRA Configuration Tool:

(info) Please Note: You may need to set the JAVA_HOME environment variable to run the JIRA Configuration Tool. See Installing Java for details.

To connect JIRA to MySQL using the JIRA Configuration Tool:

  1. Click the 'Database' tab.
  2. From the 'Database type' drop-down choose 'MySQL'.
    (info) The JIRA Configuration Tool will display your current database configuration settings if any are already set.
  3. Fill in the connection details for your MySQL database.
    • 'Hostname' — The name or IP address of the machine that the MySQL server is installed on.
    • 'Port' — The TCP/IP port that the MySQL server is listening on. You can leave this blank to use the default port.
    • 'Database' — The name of your MySQL database (into which JIRA will save its data).
    • 'Username' — The user that JIRA uses to connect to the MySQL server.
    • 'Password' — The user's password to authenticate with the MySQL server.
  4. JIRA keeps a pool of database connections open to the database server. You can set the maximum size of this pool in the 'Pool Size' text field.
  5. After typing in your settings, click the 'Test Connection' button to test the connection settings. The tool will attempt to connect to the database, and give a message with the results.
  6. Click 'Save' to save your settings when you are done.
    (warning) Please Note:
    • The JIRA Configuration Tool will save your database configuration to a dbconfig.xml file in your JIRA Home Directory. This tool also adds the element <validation-query>select 1</validation-query> to this file, which is usually required when running JIRA with default MySQL installations. See Surviving Connection Closures for more information.
    • JIRA must be restarted for your new settings to take effect.

Congratulations — you have finished! Proceed to 'Next Steps' below.

4.2 Connecting JIRA to MySQL Manually

  1. Edit the dbconfig.xml file at the root of your JIRA Home Directory.
    (info) If this file does not exist, create the file, copy and paste the example XML code below into this file and edit the pasted XML as required.
    (warning) When editing your dbconfig.xml file, escape the '&' characters by adding 'amp;' to the end of each one, as shown in the <url/>element below:

    (minus) Please Note:

    • The database URL in the example dbconfig.xml file content above assumes a UTF-8 database — i.e. that your database was created using a command similar to create database jiradb character set utf8;
    • If you do not specify character set utf8 when creating this database, you risk getting 'Data truncation: Data too long for column' errors when importing data or corruption of non-supported characters. See storing non-ASCII characters in MySQL for details.
    • The <validation-query>select 1</validation-query> element is usually required when configuring JIRA with default MySQL installations. See Surviving Connection Closures for more information.
    • Adding the sessionVariables=storage_engine=InnoDB parameter to the database URL is strongly recommended when configuring JIRA with MySQL, to avoid data corruption. See the Additional Notes section below for more information.
  2. Save your edited dbconfig.xml file (at the root of your JIRA Home Directory).
    (info) JIRA must be restarted for your new settings to take effect.

Proceed to 'Next Steps' below.

4.3. Additional Notes

The default storage engine used by MySQL Server versions prior to 5.5 is MyISAM. Hence, a JIRA database running on a default configuration of a MySQL Server earlier than version 5.5, could experience table creation problems (JRA-24124), which may result in data corruption in JIRA.

Hence, specifying the sessionVariables=storage_engine=InnoDB parameter in your database URL (by following the procedures above) is strongly recommended. Doing so ensures that tables written to JIRA's MySQL database will use the InnoDB storage engine, which supports 'database transactions' required by JIRA.

Be aware that JIRA uses the 'READ-COMMITTED' transaction isolation level with MySQL, which currently only supports row-based binary logging. If you require MySQL's binary logging features, you must configure MySQL's binary logging format to be 'row-based'. If not, you may encounter problems when creating issues in JIRA. For more information, please refer to JIRA Cannot Create Issues when Using MySQL with Binary Logging.

5. Next Steps

You should now have JIRA configured to connect to your MySQL database.

  • If you are using a 'recommended' distribution of JIRA, start it up and watch the logs for any errors.
  • If you are using the JIRA WAR distribution, rebuild and redeploy the webapp in your application server.

Installation Notes

Please see JIRA and MySQL.

  1. Sep 25, 2010

    Anonymous

    I have windows 7 and used MySQL 5.1.50-win64.  I found that if you ran config.bat from the command prompt, you need to run the command prompt as administrator, otherwise you get all sorts of errors.  My user is an admin user so that wasn't enough.

  2. Jan 21, 2011

    Anonymous

    This is missing the all-important line that's missing from entityengine.xml:

    <field-type name="mysql" loader="maincp" location="entitydefs/fieldtype-mysql.xml"/>

    (well, at least it was in our installation).

    Without this line, you get a message in the logfile along the lines of not being able to find a field-type description with name of "mysql".

  3. Jun 30, 2011

    Anonymous

    I suggest to do the necessary changes in the conf/server.xml file instead of the dbconfig.xml, as it would never pick the latter one.

    Now it is all in one place, and works a treat.

    1. Aug 08, 2011

      Hi there,

      Just letting you know (in case you weren't aware) that our documentation is 'versioned' (in line with major product versions).

      If you're using JIRA 4.4.x, use the procedure documented on this page. If you're using JIRA 4.3.x or earlier, use this procedure instead.

      Cheers,
      Giles.

  4. Oct 12, 2011

    Anonymous

    Are these instructions still valid as of JIRA 4.4.1? It seems that the Setup Wizard (http://confluence.atlassian.com/display/JIRA/Running+the+Setup+Wizard) is already configuring JIRA to use MySQL.

    1. Oct 12, 2011

      Hello there,

      These instructions were updated for the release of JIRA 4.4.1. However, if you noticed a discrepancy somewhere (or something that requires correction or clarification) in the documentation above, please do let us know so that we can make any appropriate amendments to the content.

      Kind regards,

      Giles.

      P.S. It might also help if you provide some background on your JIRA setup/scenario as it may assist us in finding out how your JIRA installation was already configured to use MySQL.

  5. Oct 30, 2011

    You can check the current values in mysql very easily with these commands.

    mysql>  use [insertdbname];

    mysql>  show variables like "collation_database";

    mysql>  show variables like "character_set_database";

    I think you would need to delete your database and resetup JIRA to recreate your database with the correct encoding if the values aren't correct. 

  6. Dec 22, 2011

    Hi All , 

    How do we manually upgrade mysql database backup file in JIRA 4.0 to JIRA 4.4 .

    if i took database back up of JIRA 4.0 and want to restore on database JIRA 4.4  then out of memory error coming during deployment in jboss. Is any manually procedure to upgrade database of JIRA 4.0  to JIRA 4.4 .

     

     

     

  7. Jan 17, 2012

    Anonymous

    How can you configure a second database connection. 

    To give you some background, we have a plugin that will check our second database, which basically consists of user's info, and then will automatically fill in the assignee's, developers, manager, etc. for that issue based on certain information provided when creating the issue.

    As of now we can only get our JIRA database connected and not the second database. I've searched around for some documentation, but haven't had any luck. If you could point me in the right direction that would be great!

    1. Jan 18, 2012

      Hello there,

      I haven't heard of anyone implementing such a database configuration with JIRA like this before.

      However, I'd recommend that you post specific questions such as these in our Atlassian Answers site via the Get Answers link below, as you're more likely to get greater exposure of such questions to a wider community of JIRA customers/admins/users and potentially obtain a faster responses.

      Kind regards,

      Giles.

  8. Feb 03, 2012

    Is is explicitly required to set the default transaction isolation MySQL variable on the server to be READ-COMMITTED?

    The additional notes section above suggests Jira uses that specific tx isolation level, but it's not clear if it's been assumed the server has been configured that way, or if Jira specifically creates transactions at that isolation level via JDBC itself.

    If it is required, then it should probably be stated at the start of this document, rather than the end.