1 # Start a shell for the postgres user:
2 <notextile><pre>~$ <span class="userinput">sudo -u postgres bash</span></pre></notextile>
3 # Generate a new database password:
4 <notextile><pre>$ <span class="userinput">ruby -e 'puts rand(2**128).to_s(36)'</span>
6 </pre></notextile> Record this. You'll need it when you set up the Rails server later.
7 # Create a database user with the password you generated:
8 <notextile><pre><code>$ <span class="userinput">createuser --encrypted -R -S --pwprompt {{service_role}}</span>
9 Enter password for new role: <span class="userinput">yourgeneratedpassword</span>
10 Enter it again: <span class="userinput">yourgeneratedpassword</span>
11 </code></pre></notextile>
12 # Create a database owned by the new user:
13 <notextile><pre><code>$ <span class="userinput">createdb {{service_database}} -T template0 -E UTF8 -O {{service_role}}</span></code></pre></notextile>
14 # Exit the postgres user shell:
15 <notextile><pre>$ <span class="userinput">exit</span></pre></notextile>