Install PostgreSQL using pacman:
Check it's been installed:
Before you can do anything, you must initialize a database storage area (cluster) on disk. In file system terms, a database cluster is a single directory under which all data is stored. It is completely up to you where you choose to store your data. There is no default, although locations such as /usr/local/pgsql/data or /var/lib/postgres/data are popular. This latter is my preferred.
Change the owner of the /var/lib/postgres directory and its contents to the postgres user (the default user set up by the install):
To initialize a database cluster, use the command initdb, which is installed with PostgreSQL. This must be done as the postgres user, so become this user:
Now you can logout from the postgres user and fire up PostgreSQL:
If you want PostgreSQL to start automatically every time your VPS boots up, use this:
PostgreSQL is now running. By creating another PostgreSQL user as per your local Arch user ($USER), you can access the PostgreSQL database shell directly instead of having to log in as the postgres user:
(Substitute myUsualArchLoginName for your Arch login name.)
Now you can create databases and access them as an Arch user. Here's an example:
Use the psql command to access the PostgreSQL database shell, psql. (-d specifies the database to connect to.)
Since you have yet to create any tables and input any data into this database, just list all the database's users and their permissions:
You should have two users: postgres and your Arch login user.
Type \q or CTRL+d to exit the PostgreSQL database shell back to your command line.
|\c databaseName||connect to a particular database|
|\du||list all users and their permission levels|
|\dt||shows summary information about all tables in the current database|
|\q or CTRL+d||exit/quit the psql shell|
The PostgreSQL database server configuration file is postgresql.conf. This file is located in the data directory of the server, typically /var/lib/postgres/data. This folder also houses the other main config files, including the pg_hba.conf.
Note: By default this folder will not even be browseable (or searchable) by a regular user, if you are wondering why find or locate is not finding the conf files, this is the reason.