Browse Source

Begins PostgreSQL setup review

Adrien Panay 7 years ago
parent
commit
27e298e87d
1 changed files with 18 additions and 7 deletions
  1. 18 7
      doc/database.md

+ 18 - 7
doc/database.md View File

32
 
32
 
33
 #### Creating a user and associated database ####
33
 #### Creating a user and associated database ####
34
 
34
 
35
-You need a database and associated user/password. Tracim comes with `pgtool`, tool that will make this step easy:
35
+##### With `psql`, the `PostgreSQL` interactive terminal
36
+
37
+    sudo --user=postgres psql \
38
+         --command='CREATE USER tracimuser WITH PASSWORD tracimpassword;' \
39
+         --command='CREATE DATABASE tracimdb OWNER TO tracimuser;'
40
+[//]: # (The following lines should only be necessary to fix permissions on an existing database:)
41
+[//]: # (    sudo --user=postgres psql \)
42
+[//]: # (         --dbname=tracimdb \)
43
+[//]: # (         --command='GRANT ALL PRIVILEGES ON DATABASE tracimdb TO tracimuser;' \)
44
+[//]: # (         --command='GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO tracimuser;')
45
+
46
+##### With `pgtool`
47
+
48
+Tracim comes with `pgtool` to ease this step:
36
 
49
 
37
     ./bin/pgtool help
50
     ./bin/pgtool help
38
 
51
 
44
     ./bin/pgtool grant_all_privileges tracimdb tracimuser
57
     ./bin/pgtool grant_all_privileges tracimdb tracimuser
45
     exit
58
     exit
46
 
59
 
47
-#### Test the database access ####
48
-
49
-So, now you have a database and an associated user/password. A good habit is to test things before to use them, that's why we want to test the database access. This is easily done with Tracim `pgtool`:
60
+Test the database access:
50
 
61
 
51
     ./bin/pgtool test_connection tracimdb tracimuser tracimpassword 127.0.0.1
62
     ./bin/pgtool test_connection tracimdb tracimuser tracimpassword 127.0.0.1
52
 
63
 
53
-The result is similar to the following :
64
+Success output:
54
 
65
 
55
     PG # CONNECT TO DATABASE
66
     PG # CONNECT TO DATABASE
56
     ------------------------
67
     ------------------------
63
      2014-11-10 09:40:23.306199+01
74
      2014-11-10 09:40:23.306199+01
64
     (1 row)
75
     (1 row)
65
 
76
 
66
-In case of failure, you would get something like this:
77
+Failure output:
67
 
78
 
68
     PG # CONNECT TO DATABASE
79
     PG # CONNECT TO DATABASE
69
     ------------------------
80
     ------------------------
75
     FATAL:  password authentication failed for user "bibi"
86
     FATAL:  password authentication failed for user "bibi"
76
     ERRROR
87
     ERRROR
77
 
88
 
78
-In this case, delete the user and database you previously created, using `pgtool`, and do it again. Do not forget to run the `grant_all_rights` command!
89
+In this case, delete the user and database you previously created using `pgtool`, and do it again.
79
 
90
 
80
 ## MySQL ##
91
 ## MySQL ##
81
 
92