-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostgres
More file actions
178 lines (136 loc) · 7.33 KB
/
Copy pathpostgres
File metadata and controls
178 lines (136 loc) · 7.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
====================================================================================
POSTGRES MAC
brew services start/stop/restart postgres
#### CREATE DATABASE 1
sudo -u luisvargas createuser -P DATABASE_NAME;
Enter password for new role:
Enter it again:
sudo -u luisvargas createdb DATABASE_NAME -O DATABASE_OWNER;
#### CREATE DATABASE 2
sudo psql -U luisvargas postgres
postgres=# create database DATABASE_NAME;
CREATE DATABASE
postgres=# create ROLE ROLE_NAME;
CREATE ROLE
postgres=# ALTER USER DATABASE_OWNER WITH SUPERUSER;
ALTER ROLE
ppostgres=# ALTER DATABASE DATABASE_NAME OWNER TO DATABASE_OWNER;
ALTER DATABASE
postgres=#
CREATE models in DB
python manage.py syncdb --all && python manage.py migrate --fake
POPULATE database
Password:
psql (10.4)
Type "help" for help.
postgres=# \du
List of roles
Role name | Attributes | Member of
------------+------------------------------------------------------------+-----------
luisvargas | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
DATABASE_NAME | | {}
postgres | Superuser | {}
profiles | Superuser, Create role, Create DB | {}
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+------------+----------+-------------+-------------+---------------------------
DATABASE_NAME | DATABASE_NAME | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
profiles | profiles | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/luisvargas +
| | | | | luisvargas=CTc/luisvargas
template1 | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/luisvargas +
| | | | | luisvargas=CTc/luisvargas
(5 rows)
postgres=# ALTER USER
USER USER MAPPING FOR
postgres=# ALTER USER DATABASE_NAME WITH SUPERUSER;
ALTER ROLE
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+------------+----------+-------------+-------------+---------------------------
DATABASE_NAME | DATABASE_NAME | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
profiles | profiles | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/luisvargas +
| | | | | luisvargas=CTc/luisvargas
template1 | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/luisvargas +
| | | | | luisvargas=CTc/luisvargas
(5 rows)
postgres=# \du
List of roles
Role name | Attributes | Member of
------------+------------------------------------------------------------+-----------
luisvargas | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
DATABASE_NAME | Superuser | {}
postgres | Superuser | {}
profiles | Superuser, Create role, Create DB | {}
postgres=#
DELETE DATABASE
postgres=# drop database DATABASE_NAME;
ERROR: database "DATABASE_NAME" is being accessed by other users
DETAIL: There is 1 other session using the database.
FIX: stop pgAdmin
====================================================================================
POSTGRES LINUX
DELETE DATABASE
/NG/DATABASE_NAME(venv3957) (feature/NGPAPI-3834*)$ sudo su postgres
psql
postgres=# drop database DATABASE_NAME;
sudo -u luisvargas createuser -P DATABASE_NAME;
Enter password for new role:
Enter it again:
(DATABASE_NAME) DATABASE_NAME (feature/ST-4017) ✗
➜ sudo -u luisvargas createdb DATABASE_NAME -O DATABASE_NAME;
(DATABASE_NAME) DATABASE_NAME (feature/ST-4017) ✗
➜ sudo psql -U luisvargas postgres
Password:
psql (10.4)
Type "help" for help.
postgres=# \du
List of roles
Role name | Attributes | Member of
------------+------------------------------------------------------------+-----------
luisvargas | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
DATABASE_NAME | | {}
postgres | Superuser | {}
profiles | Superuser, Create role, Create DB | {}
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+------------+----------+-------------+-------------+---------------------------
DATABASE_NAME | DATABASE_NAME | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
profiles | profiles | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/luisvargas +
| | | | | luisvargas=CTc/luisvargas
template1 | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/luisvargas +
| | | | | luisvargas=CTc/luisvargas
(5 rows)
postgres=# ALTER USER
USER USER MAPPING FOR
postgres=# ALTER USER DATABASE_NAME WITH SUPERUSER;
ALTER ROLE
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+------------+----------+-------------+-------------+---------------------------
DATABASE_NAME | DATABASE_NAME | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
profiles | profiles | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/luisvargas +
| | | | | luisvargas=CTc/luisvargas
template1 | luisvargas | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/luisvargas +
| | | | | luisvargas=CTc/luisvargas
(5 rows)
postgres=# \du
List of roles
Role name | Attributes | Member of
------------+------------------------------------------------------------+-----------
luisvargas | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
DATABASE_NAME | Superuser | {}
postgres | Superuser | {}
profiles | Superuser, Create role, Create DB | {}
postgres=#