m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/postgres.md
diff options
context:
space:
mode:
Diffstat (limited to 'postgres.md')
-rw-r--r--postgres.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/postgres.md b/postgres.md
new file mode 100644
index 0000000..ddca2e5
--- /dev/null
+++ b/postgres.md
@@ -0,0 +1,35 @@
+# The PostgreSQL DBMS
+
+Default user, db: `postgres`
+
+## `psql` CLI
+
+ psql <database> <user>
+
+### Meta commands
+
+- `\c[onnect]`: connects to a database, new server (can specify dbname, username,
+host, port, etc., use `-` to leave unspecfied)
+- `\dt`: list tables
+ - There's a bunch of complicated `\d*` commands
+
+## User management
+
+Everything should be done as user `postgres`.
+
+New user:
+
+ createuser --pwprompt mypguser
+
+Change password:
+
+ # in `psql`
+ ALTER ROLE user WITH PASSWORD 'xxx';
+
+## New database
+
+ sudo su postgres
+ createdb -O mypguser mypgdatabase
+
+ # delete db
+ dropdb mypgdatabase