PostgreSQL⚓︎
Starting point to learn about this open source relational database through Ditto's setup
Resource: PostgreSQL.org
What you need⚓︎
Move to the directory where your database is installed. These examples are part of the process of learning about Ditto, a way to setup a nostr community in a VPS. However, they may be useful for postgresql database use in general.
The database directory for ditto is /opt/ditto
create⚓︎
create user⚓︎
create database⚓︎
update⚓︎
update your database password⚓︎
ALTER USER yourusername WITH PASSWORD 'yournewdatabasepassword';
access database⚓︎
the standard name for postgresql databases is postgres
psql ((Ubuntu version))
Type "help" for help.
yourdatabase=#
config file⚓︎
config_file
-----------------------------------------
/etc/file_route.conf
(1 row)
postgres=#
make changes to config file⚓︎
I followed this process to try to fix error in ditto VPS setup. It may also be useful for changing access port numbers.
source: CURSO VPS - Instalando PostgresQL en Ubuntu y configurar el acceso remoto
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
#listen_addresses = 'localhost' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
#listen_addresses = 'localhost' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
listen_addresses = '*'
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
save changes Ctrl + O, then enter exit config window with Ctrl + X
Always restart after making changes to config files.
Since I used this process to troubleshoot ditto, I then checked if ditto was running:
not running, same error
Modifying the PostgreSQL Client Authentication Configuration File
Route copied from config file
# PostgreSQL Client Authentication Configuration File
# ===================================================
...
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
check if ditto is running
● ditto.service - Ditto
Loaded: loaded (/etc/systemd/system/ditto.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since
Process: 64502 ExecStart=/usr/local/bin/deno task start (code=exited, status=1/FAILURE)
Main PID: 64502 (code=exited, status=1/FAILURE)
same error
log in as dittodbuser⚓︎
log in as dittouser to dittodb
usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
...
psql (Ubuntu version)
Type "help" for help.
ditto=> help
You are using psql, the command-line interface to PostgreSQL.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
dittodbuser=>
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+-------+-----------------------
dittodb | dittodbuser | ... | ... | ... |
postgres | postgres | ... | ... | ... |
template0 | postgres | ... | ... | ... | ...
(3 rows)
You can have multiple databases but need to make sure you point to the one you want in your .env file.
Getting a lot of non-parsed characters and a few mentions of fatal errors, but nothing specific that would point to a possible fix. I'll review later in more detail.
delete database⚓︎