WSO2 Governance Registry - Setting up Database - MySQL [ Documentation Index ]

WSO2 Governance Registry - Setting up Database - MySQL

Table of Contents

Setup Database And The Database User

  1. Download and install MySQL in you computer, if it is not already done. And Start the MySQL service.
  2. log in to mysql client using root user (Or any other user with the privilege to create databases). mysql -u root -p You will be prompted to enter the password. (In most systems the default root password is blank. Press enter without typing anything if you haven't changed the default root password). This will present you the MySQL command prompt.
  3. In the MySQL prompt, create the registry database using the following command. create database regdb;
  4. Now give authorization of the registry database to the user "regadmin". GRANT ALL ON regdb.* TO regadmin@localhost IDENTIFIED BY "regadmin"Now logout from the mysql prompt by typing the "quit" commanad. quit;

Setup Configuration Files

  1. Edit the registry.xml file (inside the $CARBON_HOME/conf directory) of the deployed registry instance as below. (note the highlighted configurations, You may use your own database name, username and password).
    <currentDBConfig>mysql-db</currentDBConfig>
            <dbConfig name="mysql-db">
                <url>jdbc:mysql://localhost:3306/regdb</url>
                <userName>regadmin</userName>
                <password>regadmin</password>
                <driverName>com.mysql.jdbc.Driver</driverName>
                <maxActive>80</maxActive>
                <maxWait>6000</maxWait>
                <minIdle>5</minIdle>
           </dbConfig>
    
    Explanation of the database configuraiton options.
    • url: The URL of the database
    • userName: The name of the database user
    • password: The password of the database user
    • maxActive: The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.
    • maxWait: The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or <= 0 to wait indefinitely.
    • minIdle: The minimum number of active connections that can remain idle in the pool, without extra ones being created, or 0 to create none.
  2. Edit the user-mgt.xml file (inside the $CARBON_HOME/conf directory) of the deployed instance as below. (note the highlighted configurations, You may use your own database name, username and password).
        <Database>
             <URL>jdbc:mysql://localhost:3306/regdb</URL>
             <UserName>regadmin</UserName>
             <Password>regadmin</Password>
             <Dialect>mysql</Dialect>
             <Driver>com.mysql.jdbc.Driver</Driver>
        </Database>
    

Setup Drivers

  1. Download the mysql java connector jar from http://dev.mysql.com/downloads/connector/j/5.1.html and Place it in the $CARBON_HOME/repository/components/lib directory (Here $CARBON_HOME refers to the directory where you run the WSO2 Governance Registry instance).

Create Database

Automatic Database Creation

  1. Next at the first time you start the regisry, run with the -Dsetup option, so it will create all the tables in given mysql database. wso2server.sh -Dsetup wso2server.bat -Dsetup
  2. You just configured WSO2 Governance Registry to run with MySQL database!

Manual Database Creation

  1. Run the MySQL scripts for both registry and user manager (embedded inside the Registry) databases, provided with the WSO2 Governance Registry using the below commands. (outside the mysql prompt) mysql -u regadmin -p -Dregdb < 'CARBON_HOME/dbscripts/mysql.sql'; Note: You will be prompted to enter the password for each command.
  2. start the wso2 registry instance. wso2server.sh wso2server.bat