Configure PostgreSQL Manually
Steps
To configure PostgreSQL for XWiki:
- Install PostgreSQL. Make sure you download a supported version.
- Download the PostgreSQL JDBC 4.2 driver.
- Copy the JDBC driver JAR into the XWiki web application's WEB-INF/lib directory or into the container's common library directory.
- Start PostgreSQL.
- 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; - Verify that the database was created and is listed in the available databases:
\l - Connect to the XWiki database.
\connect xwiki - Create the XWiki database user.
CREATE USER xwiki PASSWORD 'xwiki' VALID UNTIL 'infinity'; - Verify that the user was created.
\du - Grant database privileges to the XWiki user.
GRANT ALL PRIVILEGES ON DATABASE xwiki TO xwiki; - Grant schema privileges to the XWiki user.
GRANT ALL ON SCHEMA public TO xwiki; - 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> - Start XWiki.
FAQ
Why am I getting errors when running the CREATE DATABASE command for PostgreSQL?
Errors during the CREATE DATABASE step are usually caused by unsupported PostgreSQL parameters or incompatible locale settings. For example:
- Using a PostgreSQL version that does not support parameters such as LOCALE_PROVIDER = 'builtin'.
- Using an unsupported locale value (for example C.utf8 on older systems).
Can I create the database and user using command-line tools instead of psql?
Yes. You can use the PostgreSQL createuser and createdb utilities instead of the interactive terminal. Make sure they are available in your PATH.
- Create the XWiki user:
createuser xwiki -S -D -R -P -Upostgres - For PostgreSQL 17+:
createdb xwiki -Eunicode --locale-provider=builtin --builtin-locale=C.UTF-8 -Oxwiki -Upostgres --template template0 - For PostgreSQL versions before 17:
createdb xwiki -Eunicode --locale=C.utf8 -Oxwiki -Upostgres --template template0
Can I use a different database name or user?
Yes. Replace xwiki with your preferred names in the creation steps and in the connection.url property.
How can I remove the XWiki database?
Use the following command: dropdb -Upostgres xwiki.
How are subwikis stored when using PostgreSQL?
For PostgreSQL multiwiki deployments, each subwiki uses a separate schema within the same database. The recommended setting 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.