snipt

Ctrl+h for KB shortcuts

Text only

PostgreSQL: Create a user and a database, set as owner, and grant privileges.

1
2
3
CREATE USER bob WITH PASSWORD 'bazzy';
CREATE DATABASE baz WITH OWNER bob;
GRANT ALL PRIVILEGES ON DATABASE baz to foo;
https://snipt.net/embed/77daad8174ebf6c04b747a8d2617ce17/
/raw/77daad8174ebf6c04b747a8d2617ce17/
77daad8174ebf6c04b747a8d2617ce17
text
Text only
3
2019-06-27T08:01:05
True
False
False
Dec 17, 2015 at 02:24 PM
/api/public/snipt/140056/
postgresql-create-a-user-and-a-database-set-as-owner-and-grant-privileges-5a568550
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>CREATE USER bob WITH PASSWORD &#39;bazzy&#39;; </span><span id="L-2"><a name="L-2"></a>CREATE DATABASE baz WITH OWNER bob; </span><span id="L-3"><a name="L-3"></a>GRANT ALL PRIVILEGES ON DATABASE baz to foo; </span></pre></div> </td></tr></table>
postgres, postgresql, psql
1
2
3
4
5
6
7
--- 
+++ 
@@ -1,3 +1,3 @@
 CREATE USER bob WITH PASSWORD 'bazzy';
-CREATE DATABASE baz WITH OWNER 'bob';
+CREATE DATABASE baz WITH OWNER bob;
 GRANT ALL PRIVILEGES ON DATABASE baz to foo;
  • nick
  • 3 years, 6 months ago
1
2
3
4
5
6
7
8
--- 
+++ 
@@ -1,3 +1,3 @@
-CREATE USER fixme WITH PASSWORD 'bazzy';
-CREATE DATABASE baz WITH OWNER 'fixme';
+CREATE USER bob WITH PASSWORD 'bazzy';
+CREATE DATABASE baz WITH OWNER 'bob';
 GRANT ALL PRIVILEGES ON DATABASE baz to foo;
  • nick
  • 3 years, 7 months ago
1
2
3
4
5
6
7
8
--- 
+++ 
@@ -1,3 +1,3 @@
-CREATE USER foo WITH PASSWORD 'bazzy';
-CREATE DATABASE baz WITH OWNER 'wow!';
+CREATE USER fixme WITH PASSWORD 'bazzy';
+CREATE DATABASE baz WITH OWNER 'fixme';
 GRANT ALL PRIVILEGES ON DATABASE baz to foo;
  • nick
  • 3 years, 7 months ago
1
2
3
4
5
6
7
--- 
+++ 
@@ -1,3 +1,3 @@
 CREATE USER foo WITH PASSWORD 'bazzy';
-CREATE DATABASE baz WITH OWNER 'foo';
+CREATE DATABASE baz WITH OWNER 'wow!';
 GRANT ALL PRIVILEGES ON DATABASE baz to foo;
  • nick
  • 3 years, 7 months ago
1
2
3
4
5
6
7
--- 
+++ 
@@ -1,3 +1,3 @@
-CREATE USER foo WITH PASSWORD 'bar';
+CREATE USER foo WITH PASSWORD 'bazzy';
 CREATE DATABASE baz WITH OWNER 'foo';
 GRANT ALL PRIVILEGES ON DATABASE baz to foo;
  • nick
  • 3 years, 9 months ago
1
2
3
4
5
6
7
--- 
+++ 
@@ -1,3 +1,3 @@
 CREATE USER foo WITH PASSWORD 'bar';
 CREATE DATABASE baz WITH OWNER 'foo';
-GRANT ALL PRIVILEGES ON DATABASE baz to foo;
+GRANT ALL PRIVILEGES ON DATABASE baz to foo;
  • nick
  • 3 years, 9 months ago