Follow the steps below to connect CrowdID to MySQL.
1. Configure MySQL
- Create a database user which CrowdID will connect as (e.g. crowduser).
Create a database for CrowdID to store data in (e.g. crowdiddb).
This must be a different database from the one used by Crowd.
For a UTF-8 encoded database:create database crowdiddb character set utf8;
- 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
- Download the latest MySQL Connector/J JDBC driver.
- Add the MySQL JDBC driver jar (
mysql-connector-java-3.x.x-bin.jar) to the following directory:- For Crowd distribution:
- Crowd 2.0.2 or later: {
CROWD_INSTALL}/apache-tomcat/lib/. - Crowd 2.0.1 or earlier: {
CROWD_INSTALL}/apache-tomcat/common/lib/.
- Crowd 2.0.2 or later: {
- For Crowd WAR distribution, copy the driver JAR to your application server. For example, on Tomcat:
- Tomcat 5.5.x:
common/lib/. - Tomcat 6.x:
lib/.
- Tomcat 5.5.x:
- For Crowd distribution:
Do not place the Debug Driver (mysql-connector-java-3.x.x-bin-g.jar) on the |
3. Configure your Application Server to Connect to MySQL
Edit the file
apache-tomcat-X.X.XX/conf/Catalina/localhost/openidserver.xmland customise the username, password, driverClassName and urlparameters for the Datasource.<Context path="/openidserver" docBase="../../crowd-openidserver-webapp" debug="0"> <Resource name="jdbc/CrowdIDDS" 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/crowdiddb?autoReconnect=true&useUnicode=true&characterEncoding=utf8" [ 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 — i.e. created with
create database crowdiddb character set utf8;.
MySQL closes idle connections after 8 hours, so the
autoReconnect=trueis necessary to tell the driver to reconnect.- Delete the minEvictableIdleTimeMillis, timeBetweenEvictionRunsMillis and maxActive attributes (which are only needed for HSQL, and degrade performance otherwise).
4. Configure CrowdID to use MySQL
Edit the
build.propertiesfile (located in the root of the Crowd distribution, not Crowd EAR-WAR) and modify the hibernate.dialect to the following. Please choose only 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.MySQLMyISAMDialect
- Then run
./build.shorbuild.bat. This will configure CrowdID 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-openidserver-webapp\WEB-INF\classes\jdbc.properties. Modify the file to the following:
# - Crowd Configuration Options hibernate.connection.datasource=java\:comp/env/jdbc/CrowdIDDS 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 CrowdID configured to use the correct database. Now start up CrowdID and watch the logs for any errors.
RELATED TOPICS
- Supported Platforms
- Installing Crowd and CrowdID
- Running the Setup Wizard
- Configuring Crowd







4 Comments
Hide/Show CommentsJan 07, 2011
Chad Beaudin
These instructions refer to the
mysql-connector-java-3.x.x-bin.jar. However, theConnecting Crowd To A Databaserefer to themysql-connector-java-5.x.x-bin.jar. Should the crowdID MySQL instructions also be referring to the5.x.x jar?Jan 07, 2011
Chad Beaudin
When using MySQL, step 4 states: For MySQL with InnoDB set:
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
However when running through the setup wizard for Crowd and selecting MySQL as the JDBC connection the "Hibernate Dialect" field is pre-populated with "org.hibernate.dialect.MySQL5InnoDBDialect"
Should CrowdID also be using MySQL5InnoDBDialect?
May 26, 2011
Foo Guan Sim [Atlassian]
I also noticed that setting hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect causes some table creation exceptions (SQL Syntax error, since the table creation syntax ends with Engine=InnoDB - Incompatible with MySQL5). Reverting it back to hibernate.dialect=org.hibernate.dialect.MySQLDialect is a temporary solution, although, I think Chad's suggestion is cleaner and is worth a try.
Nov 10, 2011
Anonymous
If you are using MySQL 5.x you will need to set your dialect to
or it will fail to create your CrowdID tables.
Add Comment