`
dinguangx
  • 浏览: 240695 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

[ofbiz]ofbiz数据库切换为mysql

阅读更多

 

1. 预先在mysql中创建好数据库ofbiz及用户

create database ofbiz;
create database ofbizolap;
create database ofbiztenant;
use mysql;
create user ofbiz@localhost;
update user set password=password("ofbiz") where user='ofbiz';
grant all privileges on *.* to ofbiz@localhost identified by 'ofbiz';

 

2. 下载mysql驱动

./ant download-mySQL-JDBC

 

此命令会将mysql驱动包下载到framework/entity/lib/jdbc/目录

 

 

3. 更改entity配置

修改文件frarework/entity/config/entityengine.xml

3.1 配置mysql数据源连接,修改相关的字符集

character-set="utf8"   
collate="utf8_general_ci"

 

VI操作:

:% s/latin1_general_cs/utf8_general_ci/gc
:% s/latin1/utf8/gc

 

3.2 将delegator中引用的datasource-name的值设置为 localmysql: 

     

<delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false">
        <group-map group-name="org.ofbiz" datasource-name="localmysql"/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
    </delegator>
    <delegator name="default-no-eca" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" entity-eca-enabled="false" distributed-cache-clear-enabled="false">
        <group-map group-name="org.ofbiz" datasource-name="localmysql"/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
    </delegator>

    <!-- be sure that your default delegator (or the one you use) uses the same datasource for test. You must run "ant load-demo" before running "ant run-tests" -->
    <delegator name="test" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main">
        <group-map group-name="org.ofbiz" datasource-name="localmysql"/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
    </delegator>

 

 

 

vi操作:

 

:% s/datasource-name="localderby/datasource-name="localmysql/gc

 

 

 

4. 数据初始化

./ant load-demo
./ant start

 

附: 如果是将数据库从derby升级为mysql,参考:

https://cwiki.apache.org/confluence/display/OFBIZ/How+to+migrate+OfBiz+from+Derby+to+MySQL+database

1
2
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics