Database Connection Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission from Liferay, Inc.
Objectives Liferay Portal Development 1.Set up MySQL 2.Create the Database 3.Populate the Database 4.Configure Tomcat to use the MySQL Database
Install MySQL Double click mysql win32.exe Install MySQL using the default settings At the MySQL.com Sign-up screen, select Skip Sign-up
Install MySQL
Click Finish to run the MySQL Server Instance Configuration Wizard Select Standard Configuration
Install MySQL Select Include Bin Directory in Windows PATH
Enter asdf for the password Retype asdf to confirm the password Select Create an anonymous account On the next screen, click Execute
Connection Error If the Connection Error window pops up, click Skip. This occurs because the data directory was not removed. If you see this screen, you will need to run the Configuration Wizard again.
Create a database called “training” 1.Click Start Run… 2.Type cmd and press Enter 3.Type mysql 4.Type create database training;
Populate your database 1.Click Start Run… 2.Type cmd and press Enter 3.Navigate to the C:\Training\liferay\ext\sql\portal directory 4.Type mysql training < portal-mysql.sql
Configure Tomcat to use MySQL 1.Go to C:\Training\liferay\tomcat\conf\Catalina\localhost 2.Open ROOT.xml with Notepad
1.Change the driverClassName from org.hsqldb.jdbcDriver to com.mysql.jdbc.Driver driverClassName=“com.mysql.jdbc.Driver” 2.Change the url from jdbc:mysql:test to url=“jdbc:mysql://localhost/training?useUnicod e=true&characterEncoding=UTF-8” 3.Change the username to root username=“root” 4.Change the password to asdf password=“asdf” Configure Tomcat to use MySQL
Deploy the MySQL Driver 1.Copy mysql.jar from C:\Training\liferay\ext\lib\development to C:\Training\liferay\ext\ext-lib\global 2.Click Start Run… 3.Type cmd and press Enter 4.Navigate to the C:\training\liferay\ext 5.Type ant deploy 6.Verify that mysql.jar was deployed to C:\Training\liferay\tomcat\common\lib\ext
Congratulations! You’ve just set up the database connection! 1.Set up MySQL 2.Created a database called training 3.Populated the database with the portal-mysql.sql script 4.Configured ROOT.xml to use the MySQL database instead of the Hypersonic database
Revision History Edward Shin8/28/2006Updated for Liferay Mark Wong9/12/2006 Updated MySQL version