Connecting JIRA to MySQL

 

Connecting JIRA to MySQL

PDF
PDF

This document applies to MySQL 3.53.x up to 5.0.x.

Note: A Linux-specific version of these instructions is available.

Note
Before you begin: If you are already using JIRA, 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.
Warning
If you are using a MySQL database with any of the following:
* JIRA 3.13 Standalone 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. Please see the Tomcat 5.5 or Tomcat 6.0 documentation for details on this issue.

1. Configure MySQL

  1. Create a database user which JIRA will connect as (e.g. jirauser).
  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:

    create database jiradb character set utf8;

    (if you want your database to be named jiradb).

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

2. Copy the MySQL driver to your application server

  1. Download the MySQL Connector/J JDBC driver, eg. version 3.1.12 (tar.gz or zip) which we have verified to work. NOTE: the older 3.1.11 driver is broken.
    Note
    A user has reported encountering problems using the Resin JDBC driver for MySQL. However, the Connector/J driver from MySQL works correctly ( except for version 3.1.11).
  2. Add the MySQL JDBC driver jar (mysql-connector-java-3.x.x-bin.jar) to the common/lib/ directory. NOTE: Do not place the Debug Driver (mysql-connector-java-3.x.x-bin-g.jar) on the CLASSPATH as this can cause issues (JRA-8674).

3. Configure your application server to connect to MySQL

  1. Edit conf/server.xml (if you are using JIRA Standalone) and customise the username, password, driverClassName and url parameters for the Datasource. (If you are using JIRA WAR/EAR, edit the appropriate file on your application server; e.g. for Tomcat, edit conf/Catalina/localhost/jira.xml.)

    Warning
    The URL in the XML below assumes a UTF-8 database - i.e. created with create database jiradb character set utf8;. If you don't specify character set utf8 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.

    Note: if entered into an XML file, escape the '&' with '&' as follows:

    <Server port="8005" shutdown="SHUTDOWN">

    <Service name="Catalina">

    <Connector port="8080"
    maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" redirectPort="8443" acceptCount="100"
    connectionTimeout="20000" disableUploadTimeout="true" />

    <Engine name="Catalina" defaultHost="localhost">
    <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">

    <Context path="" docBase="${catalina.home}/atlassian-jira" reloadable="false">
    <Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource"
    username="[enter db username]"
    password="[enter db password]"
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost/jiradb?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF8"
    [ delete the minEvictableIdleTimeMillis and timeBetweenEvictionRunsMillis params here ]
    maxActive="20"
    validationQuery="select 1"
    />

    <Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"
    factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
    <Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false"/>
    </Context>

    </Host>
    </Engine>
    </Service>
    </Server>

    (Note: if you can't find this section at all, you've probably got the wrong file - search for mentions of 'jira' in the files under conf/.)

    Note
    MySQL closes idle connection after 8 hours, so the autoReconnect=true is necessary to tell the driver to reconnect
  2. If you are using JIRA Standalone, edit conf/server.xml, and delete the minEvictableIdleTimeMillis and timeBetweenEvictionRunsMillis attributes (which are only needed for HSQL, and degrade performance otherwise).
  3. If you want to set up connection validation for your application server (i.e. your database connections are dropping out), you will need to add the validatonQuery parameter to the Datasource and set it to "select 1". See the XML above for an example of this.

4. Configure the JIRA Entity Engine

  1. Edit atlassian-jira/WEB-INF/classes/entityengine.xml (if you are using JIRA Standalone) or edit-webapp/WEB-INF/classes/entityengine.xml (JIRA WAR/EAR), and change the field-type-name attribute to mysql. (If you forget to do this and start JIRA, it may create database tables incorrectly. See this page if this happens to you.) Also delete the schema-name="PUBLIC" attribute, if it exists:

    <!-- DATASOURCE - You will need to update this tag for your installation.

    -->
    <datasource name="defaultDS" field-type-name="mysql"
    [ delete this, if it exists: schema-name="PUBLIC" ]
    helper-class="org.ofbiz.core.entity.GenericHelperDAO"
    check-on-start="true"
    use-foreign-keys="false"
    ...
    Note
    If you are using JIRA WAR/EAR, your application server may require other changes to entityengine.xml (e.g. to customize the jndi-jdbc tag).

Next steps

You should now have an application server configured to connect to a database, and JIRA configured to use the correct database type. If you are using JIRA Standalone, start it up and watch the logs for any errors. If you are using the JIRA WAR/EAR distribution, rebuild and redeploy the webapp in your application server.

User-contributed notes

Have experiences to share with MYSQL and JIRA? We welcome your thoughts. Please see the user-contributed MYSQL notes.

 

 

备注:如果打开JIRA Web界面时报HTTP 404错误,查看JIRA安装目录下的logs/stdout.log文件,如果报无法连接数据库,查看是否是安装Mysql时把默认端口(3306)改了。如果是,运行MySQL Server Instance Config Wizard,把端口号改回来。然后重启mysql服务,重启JIRA服务,再登录JIRA Web页面就正常了(第一次启动时间比较长,属正常现象)。

 

原文:http://www.atlassian.com/software/jira/docs/v3.13.2/databases/mysql.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值