I've been having a bit of trouble trying to install PostgreSQL 14 for the first time.
I would like to apologize in advance if this question has been asked in the manner that I am about to ask it, but I do not think it has. If it has been, please direct me to the appropriate location!
I've done a fair amount of Googling on the matter, and all the information that I find seems to be rather fragmented, or I end up following a spaghetti trail of hyperlinks (a la-do-this-and-follow-this-other-link-with-more-information-than-you-need-to-understand-this-other-required-portion). Personally, I don't want to jump around to 50 different locations on the web to try and conjure up a piecemeal solution that I believe works, only to be proven wrong later. I want to know what to do and why it works. I've tried reading the documentation, and have given up on it, because to me, it seems to assume that the server has already been set up by a database administrator.
Instead of articulating my problem directly (as I seem to be having more trouble than I would like by trying to do so), I believe it would be easier to articulate my problem indirectly by stating what my expectations would be after installing PostgreSQL for the first time.
So to start, I will mention that I'm running Ubuntu 18.04.6 LTS, and am installing PostgreSQL 14.1 with the following command:
sudo apt install postgresql-14
Before continuing, I would like to add a side note in advance, that I do not want suggestions for an alternative OS or install method. I just want to be able to get "up and running" in a common-sense fashion from this exact point.
Moving on, I know that the aforementioned command creates a *nix user called postgres
.
From here, I can now indirectly state my problem using an outline of what my goals and expectations are immediately after installing the software via that command.
- After installing PostgreSQL via
apt
, these are my expected goals:- I want any client to be able to connect to the database server from any computer where a route exists from the client to the server.
- For the sake of simplicity with these stated goals, when it is directly or implicitly stated that I am trying to connect a client to the database server, I am making the assumption that the client is able to, at a minimum,
ping
the machine that the server is running on, and vice versa. - For now, I'm not completely worried about the database being accessible from the public Internet.
- I expect to be able to access the database from any computer on my LAN, whether it is an actual LAN, or some sort of logical LAN (like a WAN or a VPN).
- For the sake of simplicity with these stated goals, when it is directly or implicitly stated that I am trying to connect a client to the database server, I am making the assumption that the client is able to, at a minimum,
- If I change the PostgreSQL password of the postgres user, I expect that any client logging into the database server via the postgres user will require the password.
- This means if I want to change the password to some_password via
\password postgres
orALTER USER postgres WITH PASSWORD 'some_password';
(I am assuming this is how you change the login password of a PostgreSQL user), then...- I expect running
psql [-h host] -U postgres -W
from any host...- That when I am prompted to enter the password...
- I can only log in by entering the exact password of some_password.
- Entering any other arbitrary text for the password should not allow me to log in.
- I am adding this as a requirement because previous install attempts have shown me that this is NOT the case.
- That when I am prompted to enter the password...
- I expect running
- I expect to be able to create a PostgreSQL user account other than postgres (e.g. db_user) with a password and have it be subject to the same requirements as the postgres user.
- i.e. once the new account is given permission to log in, the same common-sense login requirements to log in must be imposed, i.e. you can't get in if you don't have the correct username/password combination.
- This means if I want to change the password to some_password via
- I want any client to be able to connect to the database server from any computer where a route exists from the client to the server.
If the process to achieve the aforementioned can be explained in such a way that it can be understood with minimal mental friction, I would be extremely grateful.
Feel free to assume that my knowledge is on par with that of a undergraduate CS student who just completed their first year of university, who also understands Linux filesystems and basic computer networking. I just want the answer to be as accessible to as many people as possible, as I am sure I'm not the only person who has struggled with installing PostgreSQL, in spite of having a power user's level of computer literacy.