6 ================================== |
6 ================================== |
7 |
7 |
8 You can `configure the database`_ system of your choice: |
8 You can `configure the database`_ system of your choice: |
9 |
9 |
10 - `PostgreSQL configuration`_ |
10 - `PostgreSQL configuration`_ |
11 - `MySql configuration`_ |
|
12 - `SQLServer configuration`_ |
11 - `SQLServer configuration`_ |
13 - `SQLite configuration`_ |
12 - `SQLite configuration`_ |
14 |
13 |
15 For advanced features, have a look to: |
14 For advanced features, have a look to: |
16 |
15 |
17 - `Cubicweb resources configuration`_ |
16 - `Cubicweb resources configuration`_ |
18 |
17 |
19 .. _`configure the database`: DatabaseInstallation_ |
18 .. _`configure the database`: DatabaseInstallation_ |
20 .. _`PostgreSQL configuration`: PostgresqlConfiguration_ |
19 .. _`PostgreSQL configuration`: PostgresqlConfiguration_ |
21 .. _`MySql configuration`: MySqlConfiguration_ |
|
22 .. _`SQLServer configuration`: SQLServerConfiguration_ |
20 .. _`SQLServer configuration`: SQLServerConfiguration_ |
23 .. _`SQLite configuration`: SQLiteConfiguration_ |
21 .. _`SQLite configuration`: SQLiteConfiguration_ |
24 .. _`Cubicweb resources configuration`: RessourcesConfiguration_ |
22 .. _`Cubicweb resources configuration`: RessourcesConfiguration_ |
25 |
23 |
26 |
24 |
39 ----------------------- |
37 ----------------------- |
40 |
38 |
41 Each instance can be configured with its own database connection information, |
39 Each instance can be configured with its own database connection information, |
42 that will be stored in the instance's :file:`sources` file. The database to use |
40 that will be stored in the instance's :file:`sources` file. The database to use |
43 will be chosen when creating the instance. CubicWeb is known to run with |
41 will be chosen when creating the instance. CubicWeb is known to run with |
44 Postgresql (recommended), SQLServer and SQLite, and may run with MySQL. |
42 Postgresql (recommended), SQLServer and SQLite. |
45 |
43 |
46 Other possible sources of data include CubicWeb, Subversion, LDAP and Mercurial, |
44 Other possible sources of data include CubicWeb, Subversion, LDAP and Mercurial, |
47 but at least one relational database is required for CubicWeb to work. You do |
45 but at least one relational database is required for CubicWeb to work. You do |
48 not need to install a backend that you do not intend to use for one of your |
46 not need to install a backend that you do not intend to use for one of your |
49 instances. SQLite is not fit for production use, but it works well for testing |
47 instances. SQLite is not fit for production use, but it works well for testing |
114 operating system user name has a matching user in the database. If not, please |
117 operating system user name has a matching user in the database. If not, please |
115 do as follow to create a user:: |
118 do as follow to create a user:: |
116 |
119 |
117 $ su |
120 $ su |
118 $ su - postgres |
121 $ su - postgres |
119 $ createuser -s -P username |
122 $ createuser -s -P <dbuser> |
120 |
123 |
121 The option `-P` (for password prompt), will encrypt the password with the |
124 The option `-P` (for password prompt), will encrypt the password with the |
122 method set in the configuration file :file:`pg_hba.conf`. If you do not use this |
125 method set in the configuration file :file:`pg_hba.conf`. If you do not use this |
123 option `-P`, then the default value will be null and you will need to set it |
126 option `-P`, then the default value will be null and you will need to set it |
124 with:: |
127 with:: |
125 |
128 |
126 $ su postgres -c "echo ALTER USER username WITH PASSWORD 'userpasswd' | psql" |
129 $ su postgres -c "echo ALTER USER <dbuser> WITH PASSWORD '<dbpassword>' | psql" |
127 |
130 |
128 The above login/password will be requested when you will create an instance with |
131 The above login/password will be requested when you will create an instance with |
129 `cubicweb-ctl create` to initialize the database of your instance. |
132 `cubicweb-ctl create` to initialize the database of your instance. |
|
133 |
|
134 |
|
135 Database creation |
|
136 +++++++++++++++++ |
|
137 |
|
138 If you create the database by hand (instead of using the `cubicweb-ctl |
|
139 db-create` tool), you may want to make sure that the local settings are |
|
140 properly set. For example, if you need to handle french accents |
|
141 properly for indexing and sorting, you may need to create the database |
|
142 with something like:: |
|
143 |
|
144 $ createdb --encoding=UTF-8 --locale=fr_FR.UTF-8 -t template0 -O <owner> <dbname> |
130 |
145 |
131 Notice that the `cubicweb-ctl db-create` does database initialization that |
146 Notice that the `cubicweb-ctl db-create` does database initialization that |
132 may requires a postgres superuser. That's why a login/password is explicitly asked |
147 may requires a postgres superuser. That's why a login/password is explicitly asked |
133 at this step, so you can use there a superuser without using this user when running |
148 at this step, so you can use there a superuser without using this user when running |
134 the instance. Things that require special privileges at this step: |
149 the instance. Things that require special privileges at this step: |
135 |
150 |
136 * database creation, require the 'create database' permission |
151 * database creation, require the 'create database' permission |
137 * install the plpython extension language (require superuser) |
152 * install the `plpython` extension language (require superuser) |
138 * install the tsearch extension for postgres version prior to 8.3 (require superuser) |
|
139 |
153 |
140 To avoid using a super user each time you create an install, a nice trick is to |
154 To avoid using a super user each time you create an install, a nice trick is to |
141 install plpython (and tsearch when needed) on the special `template1` database, |
155 install plpython (and tsearch when needed) on the special `template1` database, |
142 so they will be installed automatically when cubicweb databases are created |
156 so they will be installed automatically when cubicweb databases are created |
143 without even with needs for special access rights. To do so, run :: |
157 without needs for special access rights. To do so, run :: |
144 |
158 |
145 # Installation of plpythonu language by default :: |
159 # Installation of plpythonu language by default :: |
146 $ createlang -U pgadmin plpythonu template1 |
160 $ createlang -U pgadmin plpythonu template1 |
147 $ psql -U pgadmin template1 |
161 $ psql -U pgadmin template1 |
148 template1=# update pg_language set lanpltrusted=TRUE where lanname='plpythonu'; |
162 template1=# update pg_language set lanpltrusted=TRUE where lanname='plpythonu'; |
149 |
163 |
150 Where `pgadmin` is a postgres superuser. The last command is necessary since by |
164 Where `pgadmin` is a postgres superuser. The last command is necessary since by |
151 default plpython is an 'untrusted' language and as such can't be used by non |
165 default plpython is an 'untrusted' language and as such can't be used by non |
152 superuser. This update fix that problem by making it trusted. |
166 superuser. This update fix that problem by making it trusted. |
153 |
|
154 To install the tsearch plain-text index extension on postgres prior to 8.3, run:: |
|
155 |
|
156 cat /usr/share/postgresql/8.X/contrib/tsearch2.sql | psql -U username template1 |
|
157 |
|
158 |
|
159 .. _MySqlConfiguration: |
|
160 |
|
161 MySql |
|
162 ~~~~~ |
|
163 .. warning:: |
|
164 CubicWeb's MySQL support is not commonly used, so things may or may not work properly. |
|
165 |
|
166 You must add the following lines in ``/etc/mysql/my.cnf`` file:: |
|
167 |
|
168 transaction-isolation=READ-COMMITTED |
|
169 default-storage-engine=INNODB |
|
170 default-character-set=utf8 |
|
171 max_allowed_packet = 128M |
|
172 |
|
173 .. Note:: |
|
174 It is unclear whether mysql supports indexed string of arbitrary length or |
|
175 not. |
|
176 |
167 |
177 |
168 |
178 .. _SQLServerConfiguration: |
169 .. _SQLServerConfiguration: |
179 |
170 |
180 SQLServer |
171 SQLServer |