Configure PostgreSQL Manually

Last modified by Eleni Cojocariu on 2026/05/20 16:51

Steps

Warning

WIP

To configure PostgreSQL for XWiki:

  1. Install PostgreSQL. Make sure you download a supported version.
  2. Download the PostgreSQL JDBC 4.2 driver.
  3. Copy the JDBC driver JAR into the XWiki web application's WEB-INF/lib directory or into the container's common library directory.
  4. Start PostgreSQL.
  5. Create the XWiki database.
    CREATE DATABASE xwiki
    WITH OWNER = postgres
    ENCODING = 'UNICODE'
    LOCALE_PROVIDER = 'builtin'
    LOCALE = 'C.UTF-8'
    TABLESPACE = pg_default
    TEMPLATE = template0
    CONNECTION_LIMIT = -1;
  6. Verify that the database was created and is listed in the available databases:
    \l
  7. Connect to the XWiki database.
    \connect xwiki
  8. Create the XWiki database user.
    CREATE USER xwiki PASSWORD 'xwiki' VALID UNTIL 'infinity';
  9. Verify that the user was created.
    \du
  10. Grant database privileges to the XWiki user.
    GRANT ALL PRIVILEGES ON DATABASE xwiki TO xwiki;
  11. Grant schema privileges to the XWiki user.
    GRANT ALL ON SCHEMA public TO xwiki;
  12. Configure XWiki to use PostgreSQL.

    Edit the WEB-INF/hibernate.cfg.xml file (search fro the "PostgreSQL configuration" section in the file), uncomment it and add:

    <property name="connection.url">jdbc:postgresql://localhost:5432/xwiki</property>
    <property name="hibernate.default_schema">public</property>
  13. Start XWiki.

FAQ

Why am I getting errors when running the CREATE DATABASE command for PostgreSQL?

Errors during the CREATE DATABASE step are often caused by using PostgreSQL parameters that are not supported by your installed version or your system locale configuration. Examples:

  • Using a PostgreSQL version that does not support newer parameters such as LOCALE_PROVIDER = 'builtin'.
  • Using an incompatible locale value (for example C.utf8on older systems).

Can I create the database and user using command-line tools instead of psql?

Yes. You can use the PostgreSQL helper utilities createuser and createdb  instead of the PostgreSQL interactive terminal. Make sure that the createuser and createdb programs are available in your PATH. The examples below also assume that the postgres administrative user exists in your setup, which is the default on most Linux distributions.

  • Create the XWiki user: createuser xwiki -S -D -R -P -Upostgres.
  • Create the XWiki database: createdb xwiki -Eunicode --locale-provider=builtin --builtin-locale=C.UTF-8 -Oxwiki -Upostgres --template template0.
  • For PostgreSQL versions before 17, use: createdb xwiki -Eunicode --locale=C.utf8 -Oxwiki -Upostgres --template template0.

How can I remove the XWiki database?

Use the following command: dropdb -Upostgres xwiki.

How are subwikis stored when using PostgreSQL?

When using PostgreSQL with XWiki multiwiki deployments, each subwiki is represented as a separate PostgreSQL schema inside the same database. The recommended configuration is: <property name="xwiki.virtual_mode">schema</property>.

More

To find more about the current topic, you can search or use the table below and filter the columns to narrow your choices.

Get Connected