MySQL

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

This page describes how to connect Bamboo to a MySQL database.

On this page:

Related pages:

Troubleshooting Databases

The JDBC driver for MySQL 5.1 (JDBC Connector/J 5.1) is no longer bundled with Bamboo. You must download and install the driver yourself.

See Supported platforms for other information about the versions of MySQL supported by Bamboo.

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
  • (recommended, not required) lower_case_table_names=1

Setting lower_case_table_names=1 might break other Atlassian applications. For more information, see the steps.

 

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, where:

  • 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

With Bamboo 5.14, we're dropping the lowercase table names requirement for the external database configuration introduced in Bamboo 5.13

See See Bamboo 5.13 Release Notes

However, we still recommend setting lower_case_table_names=1

Important

Changing the value of the lower_case_table_names parameter requires an export/import of all MySQL databases, and might affect functionality of other applications that use the same MySQL installation.

To change the value of the lower_case_table_names parameter:

  1. Create a database dump for every database in your MySQL server:

    mysqldump --databases db1 > db1.sql
    mysqldump --databases db2 > db2.sql
  2. Use DROP DATABASE to drop the database that you're recreating.
  3. Stop your MySQL DB system. You must stop all applications that are using the MySQL instance.
  4. Add lower_case_table_names=1 in the [mysqld] section of your MySQL configuration file.
  5. Restart the MySQL service.
  6. Reload the mysqldump for each database to convert the database and table names to lowercase :

    mysql < db1.sql
    mysql < db2.sql

More information can be found in the MySQL documentation.

For more information about configuring character set encoding and collation for Bamboo MySQL databases, 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 — by using either JDBC or a datasource. JDBC is generally simpler and is the recommended method.

Connect using JDBC

1. Download and install the JDBC driver

The JDBC drivers for MySQL Enterprise Server are no longer bundled with Bamboo (due to licensing restrictions). You need to download and install the driver yourself.

  1. Download the MySQL Connector/J JDBC driver from the download site.
  2. Expand the downloaded zip/tar.gz file.
  3. Copy the mysql-connector-java-5.1.XX-bin.jar file from the extracted directory to the <Bamboo installation directory>/lib  directory (create the lib/ directory if it doesn't already exist). If you are using the Java Service Wrapper to start your Bamboo instance (Bamboo/wrapper/run-bamboo start), copy the mysql-connector-java-5.1.XX-bin.jar file to <Bamboo installation directory> /wrapper/lib directory.
  4. Stop Bamboo, on Windows, Linux or Mac.
  5. Restart Bamboo, on Windows, Linux or Mac.
2. Connect Bamboo to a MySQL database using JDBC
  1. Run the Setup Wizard and choose the Custom Installation method.
  2. On the 'Choose a Database Configuration' page, choose External Database > MySQL 5.1 and click Continue
  3. Ensure that Direct JDBC connection is selected and complete the following fields (as shown in the screenshot below):

    Driver Class Name

    Type 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=trueflag.

    • 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, 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 Overwrite existing data if you wish Bamboo to overwrite any tables that already exist in the database.
  5. Click Continue.

 

Screenshot: Setup JDBC Connection (MySQL)

 

Connect using a datasource

  1. Configure a datasource in your application server (consult your application server documentation for details). Please note the following:

    • 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

    • 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.

    • 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, see the MySQL documentation.

    • Datasource example: You can see an example of using 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. Choose External Database > MySQL 5.1 from the list and click Continue

  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 Overwrite existing data if you wish Bamboo to overwrite any tables that already exist in the database.

  7. Click Continue.

Screenshot 2: Setup Datasource Connection

Last modified on May 23, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.