Configure PostgreSQL Manually
Steps
To configure PostgreSQL for XWiki:
- Make sure you have already installed and configured a servlet container for XWiki (e.g. Tomcat or Jetty), with the XWiki WAR file extracted/deployed.
- Install PostgreSQL. Make sure you download a supported version.
- Download the PostgreSQL JDBC driver.
- Copy the JDBC driver JAR into the XWiki web application's WEB-INF/lib directory of the servlet container, 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;On PostgreSQL versions before 17, omit the LOCALE_PROVIDER line and use LOCALE = 'C.utf8'.
- 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; - Comment out the configuration section of the database currently active in the WEB-INF/hibernate.cfg.xml file of the expanded XWiki WAR.
- Uncomment the "PostgreSQL configuration" section of the same file, in full, including the mapping entries at its end.
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/xwiki</property> <property name="hibernate.connection.username">xwiki</property> <property name="hibernate.connection.password">xwiki</property> <property name="hibernate.connection.driver_class">org.postgresql.Driver</property> <property name="hibernate.jdbc.use_streams_for_binary">false</property> <property name="xwiki.virtual_mode">schema</property> <property name="hibernate.connection.charSet">UTF-8</property> <property name="hibernate.connection.useUnicode">true</property> <property name="hibernate.connection.characterEncoding">utf8</property> <mapping resource="xwiki.postgresql.hbm.xml"/> <mapping resource="feeds.hbm.xml"/> - Review the hibernate.connection.url property, and the user name and password, against the database you created.
- Start XWiki.
- Open your wiki in a browser. XWiki connects to PostgreSQL, creates its tables on first start, and serves the wiki without a database error.
FAQ
Why am I getting errors when running the CREATE DATABASE command for PostgreSQL?
Errors during that step usually come from a parameter your PostgreSQL version does not support, such as LOCALE_PROVIDER = 'builtin', or from an unsupported locale value such as C.utf8 on older systems.
Can I create the database and user without psql?
Yes, with the createuser and createdb utilities:
createuser xwiki -S -D -R -P -Upostgres- PostgreSQL 17 and later:
createdb xwiki -Eunicode --locale-provider=builtin --builtin-locale=C.UTF-8 -Oxwiki -Upostgres --template template0 - Before PostgreSQL 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 own names in the creation steps and in the hibernate.connection.url, hibernate.connection.username and hibernate.connection.password properties. If the main wiki's database is not named xwiki, also set the xwiki.db property in the WEB-INF/xwiki.cfg file.
How can I remove the XWiki database?
Use dropdb -Upostgres xwiki.
How are subwikis stored?
Each subwiki uses its own schema in the same database.
More
To find more about the current topic, you can search or use the table below and filter the columns to narrow your choices.