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 データベースサーバーを設定します。

注意:Confluence を既存の MySQL データベースサーバーに接続する場合、以下の説明に従って MySQL インストールウィザードで設定ステップを実行し、このデータベースサーバーを再設定することを強くお勧めします

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. Choose Transactional Database Only to ensure that your MySQL database will use InnoDB as its default storage engine.
      It is highly recommended that you only use the InnoDB storage engine with Confluence. Avoid using the MyISAM storage engine as this can lead to data corruption.
    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. Create the Confluence database user by running this command. Replace 'confluenceuser' and 'confluencepass' with a username and password of your choice. If Confluence is not running on the same server as your MySQL database server, replace 'localhost' with the hostname or IP address of the Confluence server:

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

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

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

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

Step 6. Download and install the MySQL database driver if necessary

If you are using a direct JDBC connection, you do not need to download or install any JDBC drivers. The JDBC drivers for this database are bundled with Confluence.

If you plan to set up a datasource connection to MySQL, follow the steps described in Configuring a MySQL Datasource in 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).