This page last changed on Feb 28, 2007 by justin.

1. Configure MySQL

  1. Create a database user which Crowd will connect as (e.g. crowduser).
  2. Create a database for Crowd to store data in (e.g. crowddb).
  3. Ensure that the user has permission to connect to the database, and create and populate tables

2. Copy the MySQL driver to your application server

  1. Download the latest MySQL Connector/J JDBC driver.
  2. Add the MySQL JDBC driver jar (mysql-connector-java-3.x.x-bin.jar) to the common/lib/ directory. NOTE: Do not place the Debug Driver (mysql-connector-java-3.x.x-bin-g.jar) on the CLASSPATH as this can cause issues (JRA-8674).

3. Configure your application server to connect to MySQL

  1. Edit the conf/Catalina/localhost/crowd.xml and customise the username, password, driverClassName and url parameters for the Datasource.
    <Context path="/crowd" docBase="../../crowd-webapp" debug="0">
    
        <Resource name="jdbc/CrowdDS" auth="Container" type="javax.sql.DataSource"
                  username="[enter db username here]"
                  password="[enter db password here]"
                  driverClassName="com.mysql.jdbc.Driver"
                  url="jdbc:mysql://localhost/crowddb?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=latin1"
                  [ delete the minEvictableIdleTimeMillis, timeBetweenEvictionRunsMillis and maxActive params here ]
                />
    
        <Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false"/>
    
    </Context>

    The URL above assumes a UTF-8 database - ie. created with create database crowddb character set utf8;. If you don't specify character set utf8 you risk getting 'Data truncation: Data too long for column' errors.

    MySQL closes idle connection after 8 hours, so the autoReconnect=true is necessary to tell the driver to reconnect

  2. Delete the minEvictableIdleTimeMillis, timeBetweenEvictionRunsMillis and maxActive attributes (which are only needed for HSQL, and degrade performance otherwise).

4. Configure Crowd to use MySQL

  1. Edit the build.properties file located in the root of the standalone release and modify the hibernate.dialect to the following, please only choose one of the 3 available options depending on how you have configured your database server.
    *For MySQL set:* 
    hibernate.dialect=org.hibernate.dialect.MySQLDialect
    *For MySQL with InnoDB set:* 
    hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
    *For MySQL with MyISAM set:* 
    hibernate.dialect=org.hibernate.dialect.MySQLMyISAMDDialect
    
  2. Then run the ./build.sh or build.bat, this will configure crowd to use the MySQL dialect.

If you do not wish to edit this file and run the build script, you can edit the jdbc.properties (which the above script modifies) directly. The jdbc.properties file is located here: crowd-webapp\WEB-INF\classes\jdbc.properties, modify the file to the following:

# - Crowd Configuration Options

hibernate.connection.datasource=java\:comp/env/jdbc/CrowdDS
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory

...

Next steps

You should now have an application server configured to connect to a database, and Crowd configured to use the correct database. Now start up Crowd and watch the logs for any errors.

There is an error in section 4 of this document.

If you want to use MYSQL with InnoDB, you need to use the following setting for the hibernate.dialect:

hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect

Guys, can you update this section and check the others?  

Posted by rondv5 at Jan 22, 2007 21:08
Document generated by Confluence on Mar 08, 2007 18:49