snipt

Ctrl+h for KB shortcuts

PostgreSQL console (psql)

Create user, database and grant privileges PostgreSQL

1
2
3
4
5
CREATE USER myuser WITH PASSWORD 'mypasswd';

CREATE DATABASE mydb;

GRANT ALL PRIVILEGES ON DATABASE mydb to myuser;
https://snipt.net/embed/7255150555d22d0b3eda4dee841516ae/
/raw/7255150555d22d0b3eda4dee841516ae/
7255150555d22d0b3eda4dee841516ae
psql
PostgreSQL console (psql)
7
2019-05-24T14:53:55
True
False
False
/api/public/snipt/46452/
create-user-database-and-grant-privileges-postgresql
<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> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">CREATE</span> <span class="k">USER</span> <span class="n">myuser</span> <span class="k">WITH</span> <span class="k">PASSWORD</span> <span class="s1">&#39;mypasswd&#39;</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="go">CREATE DATABASE mydb;</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="go">GRANT ALL PRIVILEGES ON DATABASE mydb to myuser;</span> </span></pre></div> </td></tr></table>
PostgreSQL, Postgres