Skip to main content

Setting up the database

This section explains how to create the required physical databases, populate them with the necessary database scripts, and configure the datasources for WSO2 Identity Server and the DPDP Accelerator.

Throughout this guide:

  • <IS_HOME> refers to the root directory of the WSO2 Identity Server 7.3.0 installation.
  • <ACCELERATOR_HOME> refers to the root directory of the extracted DPDP Accelerator distribution.

1. Create the databases​

Create four databases:

DatabaseUsed by
WSO2IDENTITY_DBIdentity Server identity and consent data
WSO2SHARED_DBIdentity Server shared data
WSO2AGENTIDENTITY_DBIdentity Server AgentIdentity datasource
WSO2DPDP_DBDPDP Accelerator data

Keep the three Identity Server databases on latin1. The shipped Identity Server scripts mix tables that are explicitly latin1 with tables that inherit the database's character set, including in foreign keys, and MySQL rejects those keys if the character sets differ. WSO2DPDP_DB holds multilingual data, so it uses utf8mb4.

CREATE DATABASE WSO2IDENTITY_DB CHARACTER SET latin1 COLLATE latin1_swedish_ci;
CREATE DATABASE WSO2SHARED_DB CHARACTER SET latin1 COLLATE latin1_swedish_ci;
CREATE DATABASE WSO2AGENTIDENTITY_DB CHARACTER SET latin1 COLLATE latin1_swedish_ci;
CREATE DATABASE WSO2DPDP_DB CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

2. Create the database tables​

To create the database tables, navigate to the script locations within <IS_HOME>/dbscripts and execute the scripts that correspond to your DBMS against the respective databases.

DatabaseScript Location
WSO2SHARED_DB<IS_HOME>/dbscripts/mysql.sql
WSO2IDENTITY_DB<IS_HOME>/dbscripts/identity/mysql.sql
WSO2IDENTITY_DB<IS_HOME>/dbscripts/consent/mysql.sql
WSO2AGENTIDENTITY_DB<IS_HOME>/dbscripts/identity/agent/mysql.sql
WSO2DPDP_DB<IS_HOME>/dbscripts/dpdp-accelerator/complaint/mysql.sql
<IS_HOME>/dbscripts/dpdp-accelerator/consent-history/mysql.sql
<IS_HOME>/dbscripts/dpdp-accelerator/event-notification/mysql.sql
Consent Migration Script

For WSO2IDENTITY_DB, execute the consent migration script located at <IS_HOME>/dbscripts/migrations/consent/mysql-migration.txt. For instructions on executing migration scripts, refer to the WSO2 Identity Server Documentation.


3. Configure the datasources​

Configure the datasources by following the sample below:

Open the <IS_HOME>/repository/conf/deployment.toml file and update the datasource configurations:

[database.identity_db]
url = "jdbc:mysql://<database-host>:3306/WSO2IDENTITY_DB?autoReconnect=true&amp;useSSL=false"
username = "<database-user>"
password = "<database-password>"
driver = "com.mysql.cj.jdbc.Driver"

[database.identity_db.pool_options]
maxActive = "150"
maxWait = "60000"
minIdle = "5"
testOnBorrow = true
validationQuery = "SELECT 1"
validationInterval = "30000"
defaultAutoCommit = false

Map the created databases to the corresponding TOML configuration sections:

DatabaseTOML Configuration
WSO2IDENTITY_DB[database.identity_db]
WSO2SHARED_DB[database.shared_db]
WSO2AGENTIDENTITY_DB[datasource.AgentIdentity]
WSO2DPDP_DB[datasource.WSO2DPDP_DB]

For custom datasources ([datasource.AgentIdentity] and [datasource.WSO2DPDP_DB]), configure them using the following format:

[datasource.WSO2DPDP_DB]
id = "WSO2DPDP_DB"
url = "jdbc:mysql://<database-host>:3306/WSO2DPDP_DB?autoReconnect=true&amp;useSSL=false"
username = "<database-user>"
password = "<database-password>"
driver = "com.mysql.cj.jdbc.Driver"
pool_options.maxActive = "150"
pool_options.maxWait = "60000"
pool_options.minIdle = "5"
pool_options.testOnBorrow = true
pool_options.validationQuery = "SELECT 1"
pool_options.validationInterval = "30000"
pool_options.defaultAutoCommit = false

4. Install the JDBC driver​

Copy the JDBC driver JAR for your database into <IS_HOME>/repository/components/lib before starting the server. The dropins directory is for OSGi bundles, not for drivers.


Next steps​

After setting up the databases, executing the scripts, and configuring datasources:

  • Continue with Configuring the Accelerator to set up server hostnames, administrator credentials, and encrypt passwords with the Cipher Tool.