Confluence 5.0 has reached end of life
Check out the [latest version] of the documentation
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:
- 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
/attachmentsfolder, 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.
- Download and save the backup file.
Step 2. Install MySQL Server
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.
Step 3. Configure MySQL Server
In this step, you will configure your MySQL database server.
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 .
To configure MySQL Server:
- Run the MySQL installation wizard:
- If you are connecting Confluence to your existing MySQL server, choose Reconfigure Instance.
- Choose Advanced Configuration.
- 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.
- 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. - Set the InnoDB Tablespace settings to your requirements. (The default settings are acceptable.)
- 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.
- 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.
- For the MySQL server's default character set, choose Best Support For Multilingualism (in other words, UTF-8). This will ensure Confluence's support for internationalisation. For more information, see Configuring Database Character Encoding.
- 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. - Select Modify Security Settings to enter and set your MySQL Server (root) access password.
- Edit the
my.cnffile (often namedmy.inion Windows operating systems) in your MySQL server. Locate the[mysqld]section in the file, and add or modify the following parameters:Specify the default character set to be UTF-8:
MySQL 4.1.3 and above[mysqld] ... character-set-server=utf8 collation-server=utf8_bin ...
MySQL 4.1.2 and below[mysqld] ... default-character-set=utf8 default-collation=utf8_bin ...
Set the default storage engine to InnoDB:
[mysqld] ... default-storage-engine=INNODB ...
Specify the value of
max_allowed_packetto be at least 32M:[mysqld] ... max_allowed_packet=32M ...
(Refer to MySQL Option Files for detailed instructions on editing
my.cnfandmy.ini.)
- Restart your MySQL server for the changes to take effect:
- On Windows, use the Windows Services manager to restart the service.
- On 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'.
Step 4. Set up your MySQL database and user
In this step you will create a database within MySQL to hold your Confluence data, and a database user with authority to access that database.
To create the database and user privileges:
- Run the '
mysql' command as a MySQL super user. The default user is 'root' with a blank password. Create an empty Confluence database schema by running this command:
CREATE DATABASE confluence CHARACTER SET utf8 COLLATE utf8_bin;
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';
Step 5. Install Confluence
Install Confluence if you have not done so already. See the Confluence Installation Guide. Stop immediately after the installation, before opening the Confluence Setup Wizard in your browser, and follow the steps below.
If you have already got part-way through the Confluence Setup Wizard, stop at the database setup step and follow the steps below. You will be able to restart the setup wizard at the same step later.
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.
Step 7. Check settings for internationalisation
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:
(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.
- Ensure that Confluence is stopped. (Make sure that the application server or service which is running Confluence has been stopped or terminated.)
Edit the properties file at
<Confluence-installation>/confluence/WEB-INF/classes/confluence-init.propertiesand change theconfluence.homeproperty 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.)
- Start Confluence again.
- 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:
- Follow the initial steps in the Confluence Setup Guide, until you reach the database setup steps.
- When prompted to choose an embedded or external database, select MySQL from the dropdown list and choose External Database.
- Choose either the direct JDBC or the datasource connection, to suit the choice you made earlier when setting up the MySQL database driver.
- For the JDBC connection: Enter
confluenceuseras the username, and the password you chose earlier. - For a datasource connection: Set the JNDI name to
java:comp/env/jdbc/confluence
- For the JDBC connection: Enter
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.
Troubleshooting
If you get the following error message
,verify that you have given theconfluenceuseruser all the required database permissions when connecting fromlocalhost.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)'
- The following page contains common issues encountered when setting up your MySQL database to work with Confluence: Database Troubleshooting for MySQL
- If Confluence complains that it is missing a class file, you may have forgotten to place the JDBC driver in the
folder, or you may possibly have placed it in the wrong folder./confluence/WEB-INF/lib - 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>/logsand<confluence-home>/logs).
