This documentation relates to an earlier version of Bamboo.
View

Unknown macro: {spacejump}

or visit the current documentation home.

These instructions will help you connect Bamboo to a MySQL 5.x database.
(MySQL 4.1 is not a supported database for use with Bamboo.)

(info) Please note, the JDBC driver for MySQL 5.x (JDBC Connector/J 5.1) is bundled with Bamboo. You do not have to download and install the driver.

1. Creating and Configuring the MySQL database

 

To connect Bamboo to an external MySQL database, you must first create and configure it. This database must be configured to use:

  • utf8 character set encoding, instead of latin1
  • utf8_bin collation
  • the InnoDB storage engine

If your MySQL database server is configured to use a storage engine other than InnoDB by default (such as MyISAM), then if possible change it to use InnoDB. Otherwise, you can configure Bamboo's JDBC connection to your MySQL database so that any tables which Bamboo creates in this database will be done using the InnoDB database engine.

A MySQL database administrator can easily create and configure a MySQL database for Bamboo by running the following MySQL commands:

mysql> CREATE DATABASE bamboo CHARACTER SET utf8 COLLATE utf8_bin;
mysql> GRANT ALL PRIVILEGES ON bamboo.* TO 'bamboouser'@'localhost' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;
mysql> QUIT

This creates an empty MySQL database for Bamboo named bamboo.

注意:

  • bamboouser — the user account name for the Bamboo MySQL database
  • localhost — the host name of the MySQL database server
  • password — the password for this user account
  • If the MySQL database and Bamboo servers are on the same physical computer, you can use localhost and not set a password by omitting IDENTIFIED BY 'password' from the 2nd MySQL statement above (if you trust the security within this computer).

For more information about configuring character set encoding and collation for Bamboo MySQL databases, please refer to the MySQL 5 documentation — Specifying Character Sets and Collations.

2. Connecting Bamboo to the MySQL database

 

Bamboo provides two ways to connect to a MySQL database — via JDBC or via a datasource. JDBC is generally simpler and is the recommended method.

Connecting via JDBC

To connect Bamboo to a MySQL database, via JDBC,

  1. Run the Setup Wizard and choose the 'Custom Installation' method.
  2. On the Choose a Database Configuration page, choose 'External Database', select 'MySQL 5.x' from the list and click the 'Continue' button. The Database Configuration page will appear.
  3. Ensure that 'Direct JDBC connection' has been chosen and complete the following fields (as shown in the screenshot below):
    • 'Driver Class Name' — Type the following: com.mysql.jdbc.Driver (if different from the default).
    • 'Database URL' — Type the URL where Bamboo will access your database (if different from the default). Your URL must include the autoReconnect=true flag.
      • If you intend to use non-Latin characters in Bamboo, ensure that your URL includes the useUnicode=true and characterEncoding=utf8 flags.
      • If your MySQL database server is configured to use a storage engine other than InnoDB by default, ensure that your URL includes the sessionVariables=storage_engine=InnoDB flag.
        If you include all of these flags, your Database URL should look similar to:
        jdbc:mysql://localhost/bamboo?autoReconnect=true&useUnicode=true&characterEncoding=utf8&sessionVariables=storage_engine=InnoDB
        (warning) If the autoReconnect=true flag is not specified, the MySQL JDBC driver will eventually time out and Bamboo will no longer be able to communicate with the database.
        For more information on the URL syntax, please see the MySQL documentation.
    • 'User Name' — Type the username that Bamboo will use to access your database. This is bamboouser defined in section 1 (above).
    • 'Password' — Type the password (if required) that Bamboo will use to access your database. This is password defined in section 1 (above). Leave this field blank if a password for the database user account was not specified.
  4. Select the 'Overwrite existing data' check box if you wish Bamboo to overwrite any tables that already exist in the database.
  5. Click 'Continue' to finish specifying your connection settings.

Screenshot 1: 'Setup JDBC Connection (MySQL)'

Connecting via a datasource

To connect Bamboo to a MySQL database, via a datasource,

  1. Configure a datasource in your application server (consult your application server documentation for details).
    (info) Ensure that the JDBC URL which you configure in your application server includes the autoReconnect=true, useUnicode=true and characterEncoding=utf8 flags, such that your database URL should look similar to:
    jdbc:mysql://localhost/bamboo?autoReconnect=true&useUnicode=true&characterEncoding=utf8
    (info) If your MySQL database server is configured to use a storage engine other than InnoDB by default, also include the sessionVariables=storage_engine=InnoDB flag in this URL.
    (warning) If the autoReconnect flag is not set, the MySQL JDBC driver will eventually time out and Bamboo will no longer be able to communicate with the database.
    For more information on the URL syntax, please see the MySQL documentation.

    Datasource example

    You can see an example of Tomcat with a MySQL database as a datasource in the following document: Tomcat and External MySQL Datasource Example.

  2. Run the Setup Wizard and choose the 'Custom Installation' method.
  3. On the Choose a Database Configuration page, choose 'External Database', select 'MySQL 5.x' from the list and click the 'Continue' button. The Database Configuration page appears.
  4. Choose 'Connect via a datasource (configured in the application server)' (as shown in the screenshot below).
  5. In the 'JNDI name' field, type the JNDI name of your datasource, as configured in your application server.
    (warning) If java:comp/env/jdbc/DataSourceName does not work, try jdbc/DataSourceName (and vice versa).
  6. Select the 'Overwrite existing data' check box if you wish Bamboo to overwrite any tables that already exist in the database.
  7. Click 'Continue' to finish specifying your connection settings.

Screenshot 2: 'Setup Datasource Connection'