Wiki source code of PostgreSQL Installation

Version 11.8 by Vincent Massol on 2013/01/29

Show last authors
1 Follow these instuctions:
2
3 * Download and install [[PostgreSQL>>http://www.postgresql.org/]]
4 * Download the appropriate [[Postgres JDBC4 driver>>http://jdbc.postgresql.org/download.html]]. You can also download it directly from the [[Maven Central Repository>>http://repo1.maven.org/maven2/postgresql/postgresql/]] and copy the JAR into your container's common lib directory or in the XWiki webapp (in ##WEB-INF/lib##)
5 * Start PostgreSQL
6 ** On Mac you could issue the following shell commands to start/stop PostgreSQL 9.1 (adapt to your version and to your setup):
7 (((
8 {{code}}
9 sudo -u postgres /Library/PostgreSQL/9.1/bin/pg_ctl start -D /Library/PostgreSQL/9.1/data
10 sudo -u postgres /Library/PostgreSQL/9.1/bin/pg_ctl stop -D /Library/PostgreSQL/9.1/data
11 {{/code}}
12 )))
13 * Create the ##xwiki## user and the ##xwiki## database:(((
14 * Using the ##psql## tool:
15 (((
16 In a shell, start the PostgreSQL interactive terminal: {{code}}psql -U <replace_with_your_admin_user_eg_postgres>{{/code}}
17
18 Create the ##xwiki## database:
19
20 {{code language="none"}}
21 CREATE DATABASE xwiki
22 WITH OWNER = <replace_with_your_admin_user_eg_postgres>
23 ENCODING = 'UNICODE'
24 TABLESPACE = pg_default;
25 {{/code}}
26
27 Verify that the ##xwiki## database is listed in the available databases: {{code}}\l{{/code}}
28
29 Connect to the ##xwiki## database: {{code}}\connect xwiki{{/code}}
30
31 Create a ##xwiki## user: {{code language="none"}}CREATE USER xwiki PASSWORD 'xwiki' VALID UNTIL 'infinity';{{/code}}
32
33 Verify that the ##xwiki## user is listed in the available users: {{code language="none"}}\du{{/code}}
34
35 Give all the permissions to the ##xwiki## user: {{code}}GRANT ALL ON SCHEMA public TO xwiki;{{/code}}
36 )))
37 * Using the ##createuser## and ##createdb## programs:
38 (((
39 {{info}}
40 Make sure that the ##createuser## and ##createdb## programs are in your ##$PATH##. The example below also assumes that the ##postgres## user exists in your setup (this is the default on Linux).
41 {{/info}}
42
43 Create the ##xwiki## user: {{code}}createuser xwiki -S -D -R -P -Upostgres{{/code}}
44
45 Create the ##xwiki## database: {{code}}createdb xwiki -Eunicode -Oxwiki -Upostgres{{/code}}
46
47 Note that if you need to remove this DB at some point you can issue:{{code}}dropdb -Upostgres xwiki{{/code}}
48 )))
49 )))
50 * Tell XWiki to use this database. To do this, edit the ##WEB-INF/hibernate.cfg.xml## file where you have expanded the XWiki WAR file and uncomment the PostgreSQL part. Make sure to review the ##connection.url## property. For example a typical value would be:{{code}}<property name="connection.url">jdbc:postgresql://localhost:5432/xwiki</property>{{/code}}
51
52 == Multiwiki Status ==
53
54 Prior to XWiki 4.5M1, multiwiki mode was not fully working specifically database creation was not working. The implementation was trying to create one database for each subwiki. This is what we call the ##database## mode. You could still use XWiki on PostGreSQL but you had to manually create the databases.
55
56 Since XWiki 4.5M1, we've switched by default to use the ##schema## mode, i.e. a subwiki is represented as a Schema in the database.
57
58 The mode used is controlled by a property in ##hibernate.cfg.xml##:
59
60 {{code}}
61 <property name="xwiki.virtual_mode">schema|database</property>
62 {{/code}}
63
64 If you use the ##database## mode, be aware that [[the issue still exists>>http://jira.xwiki.org/browse/XWIKI-8753]].

Get Connected