Liferay Beginner’s Guide
上QQ阅读APP看书,第一时间看更新

Time for action – creating the database

MySQL from the following URL: http://dev.mysql.com/downloads/mysql/5.1.html. Let us first install MySQL:

  1. Double-click on the installable file that you just downloaded, which will show the following screen:
    Time for action – creating the database
  2. Click on the Next button and accept the terms of use and again click Next, which will bring up a screen as shown in the following screenshot to select the type of setup:
    Time for action – creating the database
  3. Select the radio button next to Complete, again click on Next, and then click on Install, as shown in the following screenshot:
    Time for action – creating the database
  4. This will start the installation of MySQL and after it is done it will show a couple of screens on which you have to click Next again:
    Time for action – creating the database
  5. Once installed, it will bring up the following screen, which will ask for configuring MySQL server:
    Time for action – creating the database
  6. Make sure you have ticked the checkbox against Configure the MySQL Server Now and then click on Finish, which will show up the starting screen. Click on the Next button to reach the following screen:
    Time for action – creating the database
  7. Select Detailed Configuration as shown in the preceding screenshot and click on Next, which would show you a screen to select a server type as shown in the following screenshot:
    Time for action – creating the database
  8. The memory, CPU usage, and disk usage would be decided based on the server type. For the moment, select Developer Machine and click on the Next option, which will show you the following screen:
    Time for action – creating the database
  9. Keep the default selection, Multifunctional Database, and click on the Next button, which will ask you to select path for the data file. Keep the default settings and click on Next, which will bring up the following screen:
    Time for action – creating the database
  10. Select the default option, which is for DSS/OLAP to have 20 concurrent connections to the server, and click on Next. This will open up a screen showing the default port on which MySQL server will be running. Leave the default and click on Next, which will show the following screen:
    Time for action – creating the database
  11. Select the option Manual Selected Default Character Set/Collation and from the Character Set drop-down select utf8 and then click Next to show up the following screen:
    Time for action – creating the database
  12. Leave the option to install MySQL as window service and enable the checkbox to include bin directory of MySQL to Windows PATH variable so that we can run MySQL from command prompt. Click on Next to show the following screen:
    Time for action – creating the database
  13. Give the root password to root as of now and then click on Next which will bring up the final screen as shown in the following screenshot and click on Next, which will show the following screen:
    Time for action – creating the database
  14. Click on the Execute button to configure the server. To make sure MySQL has been properly installed open up your command prompt and type mysql –u root – p and press Enter. This will ask for a password. Give the password as root and press Enter again and it should show the following screen:
    Time for action – creating the database
  15. Now, to create the database issue the following command:
    CREATE DATABASE neighbourhood_portal CHARACTER SET utf8;
    
  16. This will create a database as shown in the following screen:
    Time for action – creating the database
  17. Next, we will create a user and grant him admin rights on our table so that he is just able to work with our database. Type the following in the command prompt and press Enter:
    GRANT ALL PRIVILEGES ON neighbourhood_portal.* to admin@localhost IDENTIFIED AS ‘root';
    

What just happened?

Your database has just been created and you have created a user called admin whose password would be root and he has been given all the privileges on our neighbourhood_portal database.

Configuring Liferay to use MySQL

In Liferay, most of the configuration-related settings are done in a property file called portal.properties . Our database-related property is specified in this file too. This property is packaged in a jar called portal-impl.jar, which can be found in WEB-INF/lib of the Liferay web application. More on this property file will be discussed in later chapters. But for now, just assume that any modifications required for changing the settings of Liferay should not be made by directly editing this. Then how do we go about doing this?

The answer is that portal-ext.properties. portal-ext.properties can be saved at two places. The first is inside WEB-INF/classes of your Liferay Portal web application. This can usually be used for any property addition that developers want to control and add. The second place is in LIFERAY_HOME for more accessible changes by system admins, so that they can add database or mail server-related settings or any system-related properties.