Setting up the MySQL database for Alfresco
The official documentation is at: http://docs.alfresco.com This page describes how to download, install, and set up the MySQL database for use with Alfresco. For information on using other databases, see Using Alfresco with other databases than MySQL.
Download and install MySQL
Note: Alfresco requires MySQL 4.1 or higher.
To download and install MySQL:
- Browse to http://dev.mysql.com/downloads/mysql.
- Download the MySQL package.
- Navigate to your download location, and unzip the MySQL package.
- Double-click the setup.exe to start the MySQL Wizard.
- Use the Typical setup.
- Configure using the following options:
- for non-English or non-West European languages, choose UTF8 Character set
- install as a Windows service
- include MySQL in path
Note: Make sure that MySQL is configured using InnoDB engine, as this is needed to support transactions. Most of the time this is already the default selection.
Test MySQL is installed and running by opening a command prompt and enter:
mysql -u root -p
Installing the MySQL database connector
When installing Alfresco with MySQL, you must install the MySQL database connector. The database connector allows MySQL database to talk to the Alfresco server.
To install the MySQL database connector:
- Browse to the MySQL download site: http://dev.mysql.com/
- Download the MySQL Java Database Connector.
- Copy the JAR file into <container>/common/lib (for Tomcat).
Create a new database
To create the MySQL database for Alfresco to use: (Version 3 will create the database for you)
- Open a command prompt.
cd c:\alfresco\extras\databases\mysql, and press Enter.
db_setup, and press Enter.
- At the prompt, enter the password that you use for MySQL, and press Enter. The database is prepared
Note: On Linux one can use:
$ mysql -u root -p < db_setup.sql
If the setup is correct, a MySQL database is created with the following properties:
- Database name is alfresco
- Database user name is alfresco
- Database password is alfresco
If the setup is incorrect, the following message may appear:
'mysql' is not recognized as an internal or external command
If you receive the previous error message, add the mysql command to the Windows Path variable, and try to create a MySQL database again.
To confirm that the database is created:
- Log into MySQL by typing mysql -u root -p.
- At the mysql prompt, type show databases;
A list of databases in MySQL displays, including one named alfresco.
NOTE: The database will contain NO TABLES. This is expected. The tables will be created when Alfresco is run for the first time.
Configuring the MySQL database
To replace the HSQL default database, you must modify values in both custom-repository.properties and custom-hibernate-dialect.properties, located within the extension folder.
To configure MySQL:
- Browse to the tomcat\shared\classes\alfresco\extension\ directory.
- Locate and open the following two files:
- For both files:
- Use â€œ#â€ to comment out any lines that refer to HSQL.
- Remove the â€œ#mysql#â€ from the beginning of each line for references to MySQL.
- In the custom-repository.properties, locate the following line: dir.root=...
- Edit the line to point to the directory in which you want to store Alfresco data. For example: dir.root=c:/alfresco/alf_data
Note: You can either save the file in its current location (the <extension> directory), or in another directory. If you save the file in the <extension> directory, no further action is needed because the file is already pointed to by the repository-properties bean in the <extension>/customrepository-context.xml file. If you save the file elsewhere, you must point to your customized file.