My goal is to store my postgresql database data on an external ssd hard drive that I have plugged in to a machine running Linux Ubuntu 20.04 LTS ARM x64. I am running into problems when changing the data directory in the postgresql.conf file and then restarting postgres.
psql: could not connect to server: No such file or directory
Is the server running locally and accepting connections on
Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I am aware this error occurs when there is a problem with postgres configuration. I have tried setting permissions and ownership for user postgres on the /mnt/data/postgresql/12/main directory. No luck.
Below are the steps I took:
Create mount directory
sudo mkdir /mnt/data
Mount drive to directory
sudo mount -o defaults /dev/sda1 /mnt/data
Add directory to mounted drive where I want to store postgres data
sudo mkdir -p /mnt/data/postgresql/12/main
Change the data directory to /mnt/data/postgresql/12/main
sudo nano /etc/postgresql/12/main/postgresql.conf
Restart postgresql service
sudo systemctl restart postgresql.service