database 如何连接 Liferay 和 Mysql 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/13547725/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to connect Liferay with Mysql Database
提问by Muhammad Faizan
I am new in Liferay. I want to connect Liferay with MySQL database. I am using Liferay CE (Version? - came bundled with tomcat (6.0.29)). Please tell me the steps for this. Thank you
我是 Liferay 的新手。我想将 Liferay 与 MySQL 数据库连接。我正在使用 Liferay CE(版本? - 与 tomcat (6.0.29) 捆绑在一起)。请告诉我这样做的步骤。谢谢
回答by
To build upon what has already been mentioned already, edit the file portal-ext.properties found in liferay-portal-xxx/tomcat-xxx/webapps/ROOT/WEB-INF/classes (if it doesn't exist already then create it).
为了建立已经提到的内容,编辑在 liferay-portal-xxx/tomcat-xxx/webapps/ROOT/WEB-INF/classes 中找到的文件 portal-ext.properties(如果它不存在则创建它)。
Add these lines to it:
将这些行添加到其中:
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=<insert your mysql username>
jdbc.default.password=<insert your mysql password>
It also might be worth creating the lportal table in mysql.
在 mysql 中创建 lportal 表也可能是值得的。
mysql -u root -p <<< "create database lportal character set utf8;"
Download and extract the Liferay database scriptsfound here. Then run one, e.g.
下载并提取此处找到的Liferay 数据库脚本。然后运行一个,例如
mysql -u root -p < /path-to-the-script/create-mysql.sql
More information can be found in this Liferay Ubuntu Installation Guide(be weary as it's for an version but the database section is useful) and this Liferay Database Configuration Guide.
更多信息可以在这个Liferay Ubuntu 安装指南(因为它是一个版本但数据库部分有用)和这个Liferay 数据库配置指南中找到。
回答by Amresh
Paste the following line of code in portal-ext.properties:
将以下代码行粘贴到 portal-ext.properties 中:
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=
jdbc.default.password=
回答by Josymar De Leon
- Download Liferay CE
- Install MySQL and create a database
- Unzip liferay and create file if no exist portal.properties into liferay_home/tomcat-6.0.29/webapps/ROOT/WEB-INF/clases
- Paste this:
- 下载 Liferay CE
- 安装 MySQL 并创建数据库
- 如果没有portal.properties,则解压liferay并创建文件到liferay_home/tomcat-6.0.29/webapps/ROOT/WEB-INF/clases
- 粘贴这个:
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/nameDatabase?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.url=jdbc:mysql://localhost/nameDatabase?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=name
jdbc.default.username=name
jdbc.default.password=password
jdbc.default.password=密码
Run onm Eclipse, or Windows .bat/Linux .sh i hope works for you
在 Eclipse 或 Windows .bat/Linux .sh 上运行我希望对你有用
回答by karthik
    1)path--->home/karthik/Desktop/LiferaySetup/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes---->create an empty doc with name as portal-ext.properties
    paste the below code:
    jdbc.default.driverClassName=com.mysql.jdbc.Driver
    jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
    jdbc.default.username=root
    jdbc.default.password=root
    2)path--->/home/karthik/Desktop/LiferaySetup/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/conf/Catalina/localhost-->Enter the below code inside ROOT.xml
     <Context path="" crossContext="true">
        <!-- JAAS -->
        <!--<Realm
            className="org.apache.catalina.realm.JAASRealm"
            appName="PortalRealm"
            userClassNames="com.liferay.portal.kernel.security.jaas.PortalPrincipal"
            roleClassNames="com.liferay.portal.kernel.security.jaas.PortalRole"
        />-->
        <!--
        Uncomment the following to disable persistent sessions across reboots.
        -->
        <!--<Manager pathname="" />-->
        <!--
        Uncomment the following to not use sessions. See the property
        "session.disabled" in portal.properties.
        -->
        <!--<Manager className="com.liferay.support.tomcat.session.SessionLessManagerBase" />-->
    <Resource
        name="jdbc/LiferayPool"
        auth="Container"
        type="javax.sql.DataSource"
        driverClassName="com.mysql.jdbc.Driver"
        url="jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8"
        username="root"
        password="root"
        maxActive="20"
    />
    </Context>
If you follow the above 2 statements you can create easily

