Installation process
Setting up PostgreSQL in Manjaro Linux is very easy.
Just follow these steps and you'll have a working installation in no time.
Install the postgresql package:
sudo pacman -S postgresql postgresql-libs postgis
Switch to the postgres user account and initialize the database cluster:
sudo -i -u postgres
initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data/'
exit
Options for initdb are as follows:
--localeis the one defined in/etc/locale.conf.-Eis the default encoding for new databases.-Dis the default location for storing the database cluster.
You can have it always running when your machine starts with:
sudo systemctl enable --now postgresql.service
Otherwise, you could start, stop or restart it
when needed with:
sudo systemctl start postgresql.service
sudo systemctl stop postgresql.service
sudo systemctl restart postgresql.service
You can check PostgreSQL's version with:
psql --version
# psql (PostgreSQL) 17.4
If you are seeing a message like:
could not save history to file "/var/lib/postgres/.psql_history": No such file or directory
Enable psql history with:
sudo touch /var/lib/postgres/.psql_history
sudo chown postgres:postgres /var/lib/postgres/.psql_history
Create a DB user
Let's create a new DB user for your app:
sudo -i -u postgres psql
CREATE USER deployer WITH PASSWORD 'somepassword';
ALTER ROLE deployer WITH CREATEDB;
\q
On Phoenix you'd use this in config/dev.exs like this:
# Configure your database
config :my_app, MyApp.Repo,
username: "deployer",
password: "somepassword",
database: "my_app_dev",
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
pool_size: 10
That's it! 🎉