Skip to content

Instantly share code, notes, and snippets.

@layik
Last active January 31, 2020 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save layik/86f70308762414d7d89b8fb3fcbae9ca to your computer and use it in GitHub Desktop.
Save layik/86f70308762414d7d89b8fb3fcbae9ca to your computer and use it in GitHub Desktop.
#!/bin/bash
apt update
# install on Ubuntu
apt-get install postgresql postgresql-contrib -y
# there is now a postgres user in /etc/passwd
# easy way to start it
service postgresql start
# now everything should be done as 'postgres' userr
su - postgres -c "createdb django"
# list databases for instance
su - postgres -c "psql -c '\l'"
@layik
Copy link
Author

layik commented Jan 31, 2020

That should work on both Ubuntu and Debian.
Tested on Docker "ubuntu" and "python"

# ./psql_and_django.sh
.....
[ ok ] Starting PostgreSQL 11 database server: main.
                              List of databases
   Name    |  Owner   | Encoding | Collate |  Ctype  |   Access privileges   
-----------+----------+----------+---------+---------+-----------------------
 django    | postgres | UTF8     | C.UTF-8 | C.UTF-8 | 
 postgres  | postgres | UTF8     | C.UTF-8 | C.UTF-8 | 
 template0 | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres
 template1 | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment