JIRA の MySQL への接続

These instructions will help you connect JIRA to a MySQL database. A version of these instructions specific to Linux and JIRA is available.

はじめる前に

  • Check whether your version of MySQL is supported. See Supported Platforms.
  • 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.
  • If you plan to set up Confluence and JIRA on the same MySQL server, please read the Confluence MySQL setup guide and configure your MySQL server to suit Confluence as well as JIRA. Note that the Confluence requirements are more strict than JIRA's, so you should configure MySQL to suit Confluence. This configuration will work for JIRA too.
  • セットアップ ウィザードを実行中でなければ、はじめる前に JIRA をシャットダウンしてください。

1. MySQL データベースの作成および設定

  1. Create a database user which JIRA will connect as (e.g. jiradbuser).
    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.
    Remember this database name, as it will be used to configure JIRA's connection to this database in subsequent steps.

    CREATE DATABASE jiradb CHARACTER SET utf8 COLLATE utf8_bin;

    (データベース名を jiradb にした場合)。 

  3. 必ず、ユーザにはデータベースに接続する権限、並びにテーブルの作成・事前設定を行う権限を与えます。これは、以下の方法で行います:

    GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on <JIRADB>.* TO '<USERNAME>'@'<JIRA_SERVER_HOSTNAME>' IDENTIFIED BY '<PASSWORD>';
    flush privileges;

    ポイント:

    権限が問題無く付与されたかを確認するには、JIRA DB ユーザを利用して DB サーバにログインし、以下のコマンドを実行します:

    SHOW GRANTS FOR <USERNAME>@<JIRA_SERVER_HOSTNAME>;

2. お使いのアプリケーションサーバに MySQL JDBC ドライバーをコピーする

JIRA のアップグレードにあたって、推奨 MySQL ドライバーを利用しているのであれば (Connector/J JDBC ドライバー v5.1)、本セクションの内容をスキップして構いません。JIRA のアップグレードタスクは、既存のドライバーをアップグレードされたインストレーションへと自動的にコピーします。

お使いのアプリケーションサーバに MySQL JDBC ドライバーをコピーする:

  1. MySQL ドライバーを取得します:
    • If you are installing JIRA, download the recommended MySQL Connector/J JDBC driver v5.1.
      You can download either the .tar.gz or the .zip file by selecting the 'Platform Independent' option. Extract the jar for the driver (e.g. mysql-connector-java-5.x.x-bin.jar) from the archive.
    • If you are upgrading JIRA and you are not using the recommended MySQL driver (JDBC Connector/J 5.1), back up the driver from your JIRA installation before you upgrade.
      The driver will be in the <JIRA installation directory>/lib/ directory.
  2. Copy the MySQL JDBC driver jar to the <JIRA installation directory>/lib/ directory for your new/upgraded installation. If you are installing JIRA using the Windows installer, you will need to do this step after running the Windows installer, but before running the Setup Wizard.
  3. JIRA / JIRA サービスを再起動します。
  4. If you are installing JIRA, skip the rest of the instructions on this page and access JIRA in your browser to run the Setup Wizard instead.

注意:

  • 我々は、MySQL の Connector/J ドライバーを推奨しています(上にリンクあり)。あるユーザから、MySQL の Resin JDBC ドライバーを使用した際に問題があったという報告がありました。

3. お使いの MySQL データベースに接続するために JIRA サーバを設定します

お使いの MySQL データベースに接続するために JIRA サーバを設定するには、三つの方法があります:

  • Using the JIRA setup wizard (not applicable to JIRA WAR) — Use this method, if you have just installed JIRA and are setting it up for the first time. Your settings will be saved to the dbconfig.xml file in your JIRA Home Directory.
  • Using the JIRA configuration tool (not applicable to JIRA WAR) — Use this method, if you have an existing JIRA instance. Your settings will be saved to the dbconfig.xml file in your JIRA Home Directory.
  • Manually — Only use this method if you have a JIRA WAR instance or you have a console-only connection to your JIRA server. You will be required to manually update the dbconfig.xml file in your JIRA Home Directory.

各設定手法の手順説明

JIRA セットアップ ウィザード

ブラウザから初めて JIRA にアクセスすると、JIRA setup wizard が表示されます。

  1. 最初の画面 の “Configure Language and Database” で、 “Database Connection” に My own database を選択します。
  2. データベース タイプMySQL に設定します。
  3. 下記の データベース接続関連フィールド を参照し、フィールド入力を行います。
  4. 接続をテストし、保存します。

JIRA 設定ツール

  1. 次のように JIRA 設定ツールを実行します。
  2. データベース タブへ進み、データベースの種類 MySQL に設定します。
  3. 下記の データベース接続関連フィールド を参照し、フィールド入力を行います。
  4. 接続をテストし、保存します。
  5. Jira を再起動します。 

手動

  1. Locate the dbconfig.xml file at the root of your JIRA Home Directory.
    • If this file does not exist, create the file, copy and paste the example XML code (shown below) into this file.
  2. Update the file, as described in the Database connection fields section below. Escape any '&' characters by adding 'amp;' to the end of each one.
    • Note, the <database-type/> element must specify your type of database, e.g. mysql. If you forget to do this and you start JIRA, your database tables may be created incorrectly. See Incorrect database type specified if this happens to you.
  3. ファイルを保存し、Jira を再起動します。

データベース接続フィールド

 

セットアップウィザード / 設定ツールdbconfig.xml説明
ホスト名

<url> タグに配置されます (下記の例の太字部分):
<url>jdbc:mysql://dbserver:3306/jiradb?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=storage_engine=InnoDB</url>

MySQL サーバがインストールされている、マシンの名前あるいは IP アドレス。
ポート

<url> タグに配置されます (下記の例の太字部分):
<url>jdbc:mysql://dbserver:3306/jiradb?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=storage_engine=InnoDB</url>

MySQL サーバがリッスンしている TCP/IP ポート。デフォルトのポートを利用する際は、ここを空白にします。
データベース

<url> タグに配置されます (下記の例の太字部分):
<url>jdbc:mysql://dbserver:3306/jiradb?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=storage_engine=InnoDB</url>

お使いの MySQL データベースの名前 (JIRA データの保存先)。上記 ステップ 1で作成済みのはずです。
ユーザ名

<username> タグに配置されます (下記の例の太字部分):
<username>jiradbuser</username>

MySQL サーバに接続する際に JIRA が利用するユーザ。上記 ステップ 1で作成済みのはずです。
パスワード<password> タグに配置されます (下記の例の太字部分):
<password>jiradbuser</password>
MySQL サーバとの認証に利用する、ユーザのパスワードです。

dbconfig.xml ファイルのサンプル

  • For more information about the child elements of <jdbc-datasource/> beginning with pool in the dbconfig.xml file above, see Tuning Database Connections.
  • Both the JIRA setup wizard and database configuration tool also add 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.
  • The database URL in the example below 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 collation order of COLLATE utf8_bin is recommended for JIRA. More discussion of this can be seen at  JRA-21503 - Getting issue details... STATUS
  • The database URL in the example below contains the sessionVariables=storage_engine=InnoDB parameter. We strongly recommend adding this parameter to avoid data corruption. See the Installation Notes section below for more information.
  • For MySQL, the schema name (<schema-name>) is not used and should not be specified. If you provide a schema name, you could run into the problem described in the knowledge base article Incorrect MySQL Schema Used.
<?xml version="1.0" encoding="UTF-8"?>

<jira-database-config>
  <name>defaultDS</name>
  <delegator-name>default</delegator-name>
  <database-type>mysql</database-type>
  <jdbc-datasource>
    <url>jdbc:mysql://dbserver:3306/jiradb?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=storage_engine=InnoDB</url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <username>jiradbuser</username>
    <password>password</password>
    <pool-min-size>20</pool-min-size>
    <pool-max-size>20</pool-max-size>
    <pool-max-wait>30000</pool-max-wait>
    <pool-max-idle>20</pool-max-idle>
    <pool-remove-abandoned>true</pool-remove-abandoned>
    <pool-remove-abandoned-timeout>300</pool-remove-abandoned-timeout>
 
    <validation-query>select 1</validation-query>
    <min-evictable-idle-time-millis>60000</min-evictable-idle-time-millis>
    <time-between-eviction-runs-millis>300000</time-between-eviction-runs-millis>
  
    <pool-test-on-borrow>false</pool-test-on-borrow>
    <pool-test-while-idle>true</pool-test-while-idle>
    <validation-query-timeout>3</validation-query-timeout>
  </jdbc-datasource>
</jira-database-config>

4. JIRA を起動する

これで、MySQL データベースに接続するための JIRA の設定が完了しました。次のステップでは、これを起動させます!

  • JIRA の『推奨』ディストリビューションを使用している場合は、起動後、エラーがないかどうかログを観察します。
  • JIRA WAR ディストリビューションを使用している場合は、アプリケーションサーバーでウェブアプリケーションを再構築・再展開します。

(tick) おめでとうございます、これで MySQL データベースに JIRA が接続しました。

インストールに際して

See JIRA and MySQL. Please also take note of the following:

既知の問題およびトラブルシューティング

  • Hostnames in permissions are compared as strings - If you grant permission in MySQL to a hostname such as localhost then you must use the same string for the connecting to the database from JIRA. So using 127.0.0.1 won't work even though it resolves to the same place. This mistake produces warnings about not finding tables because the JDBC connection did not have permission to create the new tables when JIRA was set up.
  • Connection closures — If you are using a MySQL database with any of the following, you may experience problems with your connections dropping out (see JRA-15731 for details). Please read Surviving Connection Closures for information on how to address this.
    • JIRA 3.13 以上
    • Tomcat 5 のバージョン 5.5.25 以上
    • Tomcat 6 のバージョン 6.0.13 以上
  • Special characters for database password — JIRA is not able to interpret special characters for database password. Please refer to additional hints about setting password for database here.
  • Using the InnoDB storage engine — 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. We strongly recommend specifying the sessionVariables=storage_engine=InnoDB parameter in your database URL (as stated above). Doing so ensures that tables written to JIRA's MySQL database will use the InnoDB storage engine, which supports 'database transactions' required by JIRA.

  • Binary logging — 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.

  • 4 バイト文字 — JIRA は、4 バイト文字の MySQL はサポートしていませんのでご注意下さい。
Last modified on Mar 6, 2015

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.