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