Broadleaf works with a minimum MySQL version of 5.5. We recommend using the latest version.
You don't have to create a separate user and role for a broadleaf user but you can if you want. Otherwise remember the
root password and use that as your database properties
The easiest way is to use Homebrew. After Homebrew is installed, you can install MySQL by opening a Terminal and executing:
brew install mysql brew tap homebrew/services brew services restart mysql
The last 2 commands install the Homebrew services module that allows for easier manipulation of the MySQL daemon. During installation, make sure that you keep track of the username and password that you set, Broadleaf will need it for connection details.
Use your favorite package installer to install MySQL e.g.
apt-get install mysql-server
Then run the installer to complete the database setup. Keep track of the database root password, you will need it later.
For proper UTF8 configuration and ease of use across different OS's we also recommend these minimum settings in
[mysqld] lower_case_table_names=1 character-set-server=utf8 collation-server=utf8_general_ci
After updating this file you will need to restart the MySQL server
The location of
my.cnf varies on each system. This is the official MySQL reference guide for these locations. We recommend the following locations for modifying this file (this might require creating the file if it does not already exist`):
** In some versions of MySQL
/etc/my.cnfis a reserved location that has the potential to be overwritten on upgrades. If this is not an issue for you then this file can be modified
The user specific
.my.cnffile should be in the home directory that the MySQL user is running as
Create a new schema in the database (e.g.
broadleaf). If you created a new user in the installation step, make sure that your new user owns the schema and can modify tables.
In your root
pom.xml, find the following in the
<dependencies> section under the
<dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>2.3.1</version> </dependency>
and replace it with
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.26</version> </dependency>
Since you will no longer be using HSQLDB, in the root
pom.xml file, you can remove the task definitions that start and shutdown HSQLDB. Look for
<id>hsqldb-stop</id>. Delete both of those executions.
Also, if you are using the
start.sh commands in the
admin projects, you should delete the
antrun:run@hsqldb-start section. For instance, given the line that looks like:
MAVEN_OPTS="$MAVEN_OPTS $BROADLEAF_OPTS" mvn antrun:run@hsqldb-start tomcat7:run-war
Replace it with:
MAVEN_OPTS="$MAVEN_OPTS $BROADLEAF_OPTS" mvn tomcat7:run-war
core/src/main/resources/runtime-properties/common-shared.properties you will see a set of properties that look like:
blPU.hibernate.hbm2ddl.import_files_sql_extractor=org.broadleafcommerce.common.util.sql.importsql.DemoHsqlSingleLineSqlCommandExtractor blSecurePU.hibernate.hbm2ddl.import_files_sql_extractor=org.broadleafcommerce.common.util.sql.importsql.DemoHsqlSingleLineSqlCommandExtractor blCMSStorage.hibernate.hbm2ddl.import_files_sql_extractor=org.broadleafcommerce.common.util.sql.importsql.DemoHsqlSingleLineSqlCommandExtractor blEventPU.hibernate.hbm2ddl.import_files_sql_extractor=org.broadleafcommerce.common.util.sql.importsql.DemoHsqlSingleLineSqlCommandExtractor
Remove all of these properties, they will cause errors with MySQL
Update the runtime properties to use the correct MySQL dialect. In
core/src/main/resources/runtime-properties/common-shared.properties, you will want to update the three persistence unit dialects to say:
blPU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect blSecurePU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect blCMSStorage.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
You will need to update a 4th location as well:
database.properties to connect to your MySQL database. In
database.properties, you will want to update the following:
# your local database username, just a user that has readwrite permissions database.user=root # local database password database.password= database.driver=com.mysql.jdbc.Driver # this connection URL assumes that it is connecting to a schema called broadleaf database.url=jdbc:mysql://localhost:3306/broadleaf?useUnicode=true&characterEncoding=utf8
database.urlhave been changed from HSQLDB to MySQL.
Note: I named my database
broadleaf, make sure you use your database name in the url.
It is likely that you will still need to initialize and seed the new MySQL schema. Ensure that these properties are set in either
blPU.hibernate.hbm2ddl.auto=create blEventPU.hibernate.hbm2ddl.auto=create blSecurePU.hibernate.hbm2ddl.auto=create blEventPU.hibernate.hbm2ddl.auto=create
After starting up the frontend once, you can change all of these back to
update so that any data changes stay intact.
And that's it! You should now be up and running with MySQL.