This page provides instructions for configuring Confluence to use the MySQL database. If you do not already have a MySQL database driver, you will need to download the MySQL Java connector from MySQL, as described in the steps below.

Before you start, check that your version of MySQL is supported. See Supported Platforms.

Step 1. Back up your existing Confluence data

This step is required if you have existing Confluence content you wish to transfer.

To back up your Confluence data:

  1. Manually create an XML backup of Confluence. See Manually Backing Up the Site.
    • If you have less than 100MB of attachments, check 'Backup attachments' when creating the backup.
    • If you have over 100MB of attachments, you should not check the 'Backup attachments'. Instead you should manually copy the /attachments folder, located in your Confluence home (data) directory, to another location. This attachments folder can then be copied into the new home directory as described later in this guide.
  2. Download and save the backup file.

ステップ 2. MySQL サーバーをインストールする

If you do not already have an operational MySQL database server, install 'MySQL Community Edition'. Download the installation package from the MySQL download page and follow the instructions in the MySQL documentation.

ステップ 3. MySQL サーバーを設定する

このステップでは、お使いの MySQL データベースサーバーを設定します。

Note: If you intend to connect Confluence to an existing MySQL database server, we strongly recommend that you reconfigure this database server by running through the configuration steps in the MySQL installation wizard as described below.

MySQL サーバーを設定するには:

  1. MySQL インストレーションウィザードを実行します:
    1. Confluence を既存の MySQL サーバーに接続している場合、インスタンス再設定を選択します。
    2. 高度な設定 (Advanced Configuration) を選択します。
    3. Choose the type of MySQL Server that best suits your hardware requirements. This will affect the MySQL Server's usage of memory, disk and CPU resources. Refer to the MySQL documentation for further information.
    4. トランザクション データベースのみを選択して、お使いの MySQL データベースがそのデフォルト ストレージ エンジンとして InnoDB を利用する事を保証します。Confluence とは、InnoDB ストレージエンジンのみを利用する事を 強くお勧め します。MyISAM ストレージエンジンを利用するとデータ破損を引き起こす可能性があるため、その利用は控えて下さい。
    5. 要件に InnoDB テーブルスペース設定を行います (デフォルト設定でも可能です)。
    6. Set the approximate number of concurrent connections permitted to suit your Confluence usage requirements. You can use one of the presets or enter a number manually. Refer to the MySQL documentation for further information.
    7. For the networking options, ensure the Enable TCP/IP Networking and Enable Strict Mode options are selected (default). Refer to the MySQL documentation on setting the networking and server SQL modes for further information.
    8. MySQL サーバーのデフォルトのキャラクターセットに関しては、Best Support For Multilingualism (いわば、UTF-8) を選択します。これによって、国際化に対する Confluence のサポートが保証されます。詳しくはデータベース文字エンコード設定を参照して下さい。
    9. For the Windows configuration option, choose whether or not to install the MySQL Server as a Windows service. If your hardware is going to be used as a dedicated MySQL Server, you may wish to choose the options to Install As Windows Service (and Launch the MySQL Server automatically). Refer to the MySQL documentation for further information.
      Note: If you choose not to install the MySQL Server as a Windows Service, you will need to ensure that the database service has been started before running Confluence.
    10. セキュリティ設定を修正するを選択して、MySQL サーバー (ルート) アクセスパスワードの入力と設定を行います。
  2. Edit the my.cnf file (often named my.ini on Windows operating systems) in your MySQL server. Locate the [mysqld]section in the file, and add or modify the following parameters:
    • UTF-8 となるデフォルトのキャラクタセットを指定します:

      MySQL 4.1.3 または上記
      [mysqld]
      ...
      character-set-server=utf8
      collation-server=utf8_bin
      ...
      
      MySQL 4.1.2 または上記
      [mysqld]
      ...
      default-character-set=utf8
      default-collation=utf8_bin
      ...
      
    • デフォルトのストレージエンジンを InnoDB に設定します:

      [mysqld]
      ...
      default-storage-engine=INNODB
      ...
      
    • max_allowed_packet の値が 32 M 以上になるように指定します。

      [mysqld]
      ...
      max_allowed_packet=32M
      ...
      

      (Refer to MySQL Option Files for detailed instructions on editing my.cnf and my.ini.)

  3. 変更内容を有効にするには、MySQL サーバーを再起動します:
    • Windows 上では、Windows サービスマネージャーを利用してサービスを再起動します。
    • Linux の場合
      • Run one of the following commands, depending on your setup: '/etc/init.d/mysqld stop' or '/etc/init.d/mysql stop' or 'service mysqld stop'.
      • Then run the same command again, replacing 'stop' with 'start'.
    • On Mac OS X, run 'sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart'.

ステップ 4. MySQL データベースおよびユーザーのセットアップ

このステップでは、お使いの Confluence データを保持するデータベースを MySQL 内に作成し、そのデータベースにアクセスする権限のあるデータユーザーを作成します。

データベースおよびユーザー権限を作成するには:

  1. mysql コマンドを MySQL のスーパー ユーザーとして実行します。既定ユーザーは "root" でパスワードはブランクです。
  2. 次のコマンドを実行して、空の Confluence データベースのスキーマを作成します:

    CREATE DATABASE confluence CHARACTER SET utf8 COLLATE utf8_bin;
  3. 次のコマンドを実行して、Confluence データベースユーザーを作成します。'confluenceuser' と 'confluencepass' を、お好きなユーザー名とパスワードに置き替えます。 お使いの MySQL データベースサーバーと同じサーバー上で Confluence が実行されていない場合、'localhost' を Confluence サーバーのホスト名もしくは IP アドレスと置き替えます:

    GRANT ALL PRIVILEGES ON confluence.*TO 'confluenceuser'@'localhost' IDENTIFIED BY 'confluencepass';

ステップ 5. Confluence をインストールする

まだ行っていないのであれば、Confluence をインストールしましょう。Confluence インストールガイドを参照して下さい。お使いのブラウザで Confluence セットアップウィザードを開く前に、インストレーション後すぐに中断して次のステップに従います。

既に Confluence セットアップウィザードの途中まで進んだ場合、データベースセットアップのステップで止めて、以下のステップに従います。後で、同じ所から再びセットアップウィザードを再開できます。

ステップ 6. MySQL データベースドライバーのダウンロードおよびインストール

If you are upgrading Confluence and you are already using the recommended MySQL driver (JDBC Connector/J 5.1), you can skip the instructions in this section. The Confluence upgrade task will automatically copy over your existing driver to the upgraded installation.

Confluence をインストールしているか、あるいは Confluence をアップグレードしていて推奨 MySQL ドライバー (JDBC Connector/J 5.1)を利用していないのであれば、以下のステップに従います。

お使いの環境に合わせて、MySQL への JDBC直接接続あるいはデータソースへの接続 のどちらをセットアップするか選択します。不明であれば、JDBC への直接接続を選択します。

JDBC への直接接続をセットアップするには:

MySQL に対する JDBC の直接接続をセットアップする予定であれば、MySQL JDBC ドライバーをお使いの Confluence インストレーションにコピーする必要があります。

  1. MySQL ドライバーを取得します:
    • If you are installing Confluence, download the recommended MySQL driver . Links to the appropriate database drivers are available on this page: Database JDBC Drivers.
      You can download either the .tar.gz or the .zip archive. Extract the driver JAR file (for example, mysql-connector-java-x.x.x-bin.jar, where x.x.x is a version number) from the archive.
    • If you are upgrading Confluence and you are not using the recommended MySQL driver (JDBC Connector/J 5.1), copy the driver JAR file from your existing Confluence installation before you upgrade. The driver will be in the <Confluence installation>/confluence/WEB-INF/lib folder.
  2. Copy the driver JAR file to the <Confluence installation>/confluence/WEB-INF/lib folder in your new or upgraded Confluence installation.
  3. Confluence を再起動します。

データソース接続をセットアップするには:

MySQL へのデータソース接続をセットアップするのであれば、MySQL データベース を Apache Tomcat 設定において解説されたステップに従います。

ステップ 7. 国際化の設定を確認する

If you are using a existing database, use the status command to verify database character encoding information. The results should be UTF-8. See Configuring Database Character Encoding.

Step 8. Set up your database connection in Confluence

To set up your Confluence MySQL database connection or to switch to using MySQL as your external database:

  1. (If your Confluence installation does not yet have any database, you can skip this step.) If you have already set up Confluence with the built-in (HSQLDB) database, you must change your Confluence home (data) directory. 

    1. Ensure that Confluence is stopped. (Make sure that the application server or service which is running Confluence has been stopped or terminated.)
    2. Edit the properties file at <Confluence-installation>/confluence/WEB-INF/classes/confluence-init.properties and change the confluence.home property to point to a new folder. For example, if your properties file has this entry:

      confluence.home=c:/confluencedata
      

      You could change it to this:

      confluence.home=c:/confluencedata_mysql
      

      This is your new Confluence home (data) directory. (The name does not have to end in _mysql – that is just an example.)

    3. Confluence を再起動します。
  2. If have just installed Confluence and have not yet run the Confluence Setup Wizard, or you are in the middle of the Confluence Setup Wizard: Start Confluence, and go to the Confluence Setup Wizard in your browser. Follow these steps to set up the new configuration:
    1. Follow the initial steps in the Confluence Setup Guide, until you reach the database setup steps.
    2. 組み込みデータベースもしくは外部データベースの選択を促された場合、ドロップダウンリストから MySQL を選択して、外部データベースを選択します。
    3. 先ほど MySQL データベースドライバーをセットアップした際の選択と合うように、JDBC 直接接続もしくはデータソース接続を選択します。
      • For the JDBC connection: Enter confluenceuser as the username, and the password you chose earlier.
      • For a datasource connection: Set the JNDI name to java:comp/env/jdbc/confluence
    4. If you previously backed up your Confluence data, you can choose to restore it at the 'Load Content' page in the Confluence Setup Wizard. Otherwise, choose either the example or empty site as you wish.

トラブルシューティング

  • 次のエラー メッセージが表示された場合は、localhost から接続する際に必要となる全てのデータベース権限を confluenceuser ユーザーに付与したかどうかを確認します。

    Could not successfully test your database: : Server connection failure during transaction. Due to underlying exception: 'java.sql.SQLException: Access denied for user 'confluenceuser'@'localhost' (using password: YES)'
  • If Confluence complains that it is missing a class file, you may have forgotten to place the JDBC driver in the /confluence/WEB-INF/lib folder, or you may possibly have placed it in the wrong folder.
  • If none of the above describes your issue, please create a support ticket at http://support.atlassian.com and be sure to include your logs (found in <confluence-installation>/logs and <confluence-home>/logs).