Setting Up PostgreSQL On Arch26 June 2018
Photo: Austin Distel - Unsplash
Today I installed PostgreSQL on my local machine to work through some tutorials for a new language. (More on that soon). It wasn’t the most straightforward install and set up ever. Some of the steps appear to be missing or different from the Arch wiki and so I thought I would document it here.
First up install PostgreSQL in pacman with
Next, you need to initialise your database storage cluster on disk. This will be the directory which stores all the data. There is no default location but most people stick with the convention of mapping it to /var/lib/postgres/data. You can initialise this with
You then need to set the owner of that directory to be the PostgreSQL user with
Next we need to switch to the PostgreSQL user and initialise a database cluster which we do with
Once completed you can log out and start PostgreSQL with
If you want PostgreSQL to start each time you launch your machine then run
The final thing to do is to grant your usual user access to save you having to keep switching to the PostgreSQL user to access the PostgreSQL shell which you can do with
At this point, you should have a functioning PostgreSQL install.