This page last changed on Nov 17, 2010 by lamendes.

This page provides instructions for installing Confluence and the open-source MySQL database on Microsoft Windows, as well as how to set up and configure MySQL to work with Confluence. Additional instructions are also provided for migrating across any existing Confluence database content. Use this guide in conjunction with the more general Database Setup Guide for Any Database. These instructions add some important reference notes specific to MySQL.

We recommend that you use an external database with Confluence for production purposes, as the embedded database does not offer full transactional integrity in the event of sudden power loss. Confluence Standalone with MySQL is well-tested and easily configured for production purposes.

Please note the following points:
  • Throughout the instructions below, the Confluence Installation Directory refers to the directory where you extracted the Confluence zipped installer.
  • The MySQL Database Setup procedure below will make modifications to your default MySQL Server settings. These modifications result in:
    1. The default collation (localisation) option being changed to utf8_bin (that is, case-sensitive binary UTF8), such that by default, all new database tables will be created with this type of case-sensitive collation.
    2. The default MySQL database storage engine being changed to 'InnoDB'.

On this page:

1. Install Confluence

Install Confluence if you have not done so already. Ensure that you download Confluence Standalone, not the evaluation installer.

2. Install MySQL Server

To install MySQL Server,

  1. If you do not have an operational MySQL database server instance available, install 'MySQL Community Server' database server (version 5.0).
    The installation package can be downloaded from the MySQL download page or from the version 5.0 download page. Instructions for installing the MySQL 5.0 database server on Windows can found on the 'Installing MySQL on Windows' page of the MySQL web site.
  2. Run the 'MySQL Server Instance Config Wizard':
    If you intend to connect Confluence to an existing, operational MySQL database server instance, we strongly recommend that you reconfigure this database server instance by running through the Config Wizard and initially choosing the Reconfigure Instance option.
    1. At the start of the Config Wizard (or after having chosen Reconfigure Instance), choose Detailed Configuration.
    2. 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 relevant MySQL documentation for further information.
    3. Choose 'Transactional Database Only' for the database usage step. This ensures 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.
    4. Set the InnoDB Tablespace settings to your requirements.(The default settings are acceptable).
    5. Set the approximate number of concurrent connections permitted that best suits your Confluence usage requirements. You can use one of the presets if desired or enter a number manually. Refer to the relevant MySQL documentation for further information.
    6. 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.
    7. For the MySQL server instance's default character set option, choose 'Best Support For Multilingualism' (i.e. UTF-8).
    8. 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 'Install As Windows Service' (and Launch the MySQL Server automatically) options. Refer to the relevant MySQL documentation for further information.
      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.
    9. Finally, select the 'Modify Security Settings' option to enter and set your MySQL Server (root) access password.
  3. Install the database drivers, if needed:
    MySQL JDBC Drivers bundled with Confluence
    The JDBC drivers for this database are bundled with Confluence. You do not have to download or install any JDBC drivers to use this database with Confluence, if you are using a direct JDBC connection. If you are connecting via a datasource, you will still need to download and install the drivers manually. See Database JDBC drivers for more information on the bundled JDBC drivers.
    • If you are configuring a datasource to connect to your MySQL database, you will need to place the jar file (i.e. mysql-connector-java-5.x.y-bin.jar where x.y depends on the driver version) in <confluence install>/WEB-INF/lib (for Confluence 2.10 onwards) or <confluence install>/common/lib (for earlier versions). Information and links to the appropriate database drivers are available on Database JDBC drivers.
  4. Specify/Increase the value for max_allowed_packet 
    shell> mysqld \--max_allowed_packet=32M

3. Set up your MySQL Database and User

This procedure uses the MySQL Administrator application component of the MySQL GUI Tools package. If MySQL GUI Tools is not already installed or included in your MySQL installation, you will need to download and install this package before proceeding.

To create the database and user privileges,

  1. Start the 'MySQL Administrator' application and enter your login credentials when prompted to connect to the MySQL database server.
    If you ran through the 'MySQL Server Instance Config Wizard' in step 3 of the Installation and Configuration (above) and did not change your username, you should be able to connect to the MySQL database server using the default Username of 'root', Server Host of 'localhost' (assuming you are running MySQL Administrator on the same machine as the MySQL Server) and Password which you set in the Config Wizard.
    If, however, you are running MySQL for the first time and you have not yet run through the Config Wizard, or you do not recall having set your login credentials, you should be able to click OK without a Username and Password.
  2. Go to Service Control in the left pane and ensure that the MySQL Service is stopped. If not, click 'Stop Service' to stop the MySQL Service.
  3. Go to Startup Variables in the left pane and click the 'Advanced' tab.
  4. Ensure that the 'Default Collation' check box is selected, enter 'utf8_bin' for the 'Data Collation' value and click 'Apply changes'.
    If you did not run through the 'MySQL Server Instance Config Wizard' in step 3 of the Installation and Configuration (above), click the 'General Parameters' tab and ensure that the Default storage check box has been selected with its value set to InnoDB. Also, click the 'InnoDB Parameters' tab and ensure that the Activate InnoDB check box is selected. If not, implement these settings and click 'Apply changes' before proceeding.
  5. Go back to Service Control in the left pane and click 'Start Service' to re-start the MySQL Service (with the updated default collation settings).
  6. Go to Catalogs in the left pane, then right-click in the schema list at the bottom of this pane and select 'Create New Schema' from the pop-up menu.
  7. Call the new Schema name 'confluence' and click 'OK'.
  8. Go to User Administration in the left pane and then click 'Add new user' at the bottom of the window.
  9. Enter the MySQL username 'confluenceuser'.
    In fact, you can enter any legitimate MySQL username. However, the remaining steps and procedures on this page assume that you have entered the MySQL username of 'confluenceuser' at this point. If you choose a different MySQL username, substitute 'confluenceuser' in the remaining steps and procedures with your chosen MySQL username.
  10. Enter and re-confirm a password for this user and click 'Apply changes'.
  11. Right-click on the username 'confluenceuser' in the left pane and choose 'Add host from which the user can connect' from the pop-up menu.
    If prompted to enable the global 'Show hosts in user list' option, choose 'Yes'.
  12. Enter the host name 'localhost' and click 'OK'.
  13. Click on 'localhost' within 'confluenceuser' in the left pane. (You might need to click on the name 'confluenceuser' first).
  14. Click the 'Schema Privileges' tab and then click 'confluence' in the 'Schemata' list.
  15. Make sure that 'confluenceuser@localhost' has all privileges assigned to them by clicking the '<<' button to move the privileges from the 'Available' to the 'Assigned' list and click 'Apply changes'.
    To support international languages in Confluence, you should verify the newly created database is using UTF-8 encoding and re-examine the JDBC URL settings (configured in Stage 3).
For an existing database
If you're using a existing database, confirm the Character Encoding by executing the query:
SHOW VARIABLES LIKE 'character%'; and SHOW VARIABLES LIKE 'collation%';.
The results should be UTF-8.

(Optional) 4. Back Up Confluence Data

This stage is only 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 under Administration -> Backup & Restore. 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' and instead you should manually copy the /attachments directory in your Confluence home to another location. This attachments directory can then be copied into the new home directory as described later.
  2. Download the backup file to a backups folder.

5. Set Up your Database Connection

To set up your Confluence MySQL database connection or to switch to using this external database,

  1. Ensure that Confluence is stopped (for example, by ensuring that the application server or service which is running Confluence has been stopped or terminated).
  2. If you haven't started Confluence yet, you can skip this step. If you have set up Confluence with the built-in (HSQLDB) database, edit Confluence Installation Directory_/confluence/WEB-INF/classes/confluence-init.properties and change the confluence.home property to point to a new directory. e.g. if you had
    confluence.home=c:/confluencedata

    You could change it to:

    confluence.home=c:/confluencedata_mysql

    This is your new Confluence Home Directory. (The name doesn't have to end in _mysql – that's just an example)

  3. Start Confluence and set up the new configuration.
    1. Enter your license key and click the 'Custom Installation' button.
    2. Under the 'External Database' heading, select 'MySQL' from the dropdown list and click 'External Database'.
    3. On the next page, click 'Direct JDBC'.
    4. Enter confluenceuser in the User Name field, and the password you chose earlier in the Password field
    5. Click the Next button. If you get the error message 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)' verify that you have properly given the confluenceuser user all the right permissions when connecting from localhost.
    6. (optional) If you previously backed up your Confluence data, you can choose to restore it at the 'Load Content' page. Choose 'Restore From Backup', browse for the backup you created and restore it. Otherwise choose either the example or empty site as you wish.

Troubleshooting

  • Known Issues for MySQL contains common issues encountered when setting up your MySQL database to work with Confluence.
  • If Confluence is complaining that it's missing a class file, you might have forgotten to place the jdbc driver in the WEB-INF/lib folder or 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-install/logs and confluence-data/logs).

Related Documents

Document generated by Confluence on Mar 16, 2011 18:36