I installed postgresql via homebrew on my 10.7.3. The install seemed successful and I was able to start up the server. However when I try to access psql I get the following error:
psql: FATAL: role "larson" does not exist
In this case larson
is my username. Does anybody know what the issue is and what I can do to address it?
...Probably because you never created a user with that name in the Postgres system.
Postgres has its own internal authentication and authorization mechanisms for users.
The first time you connect to Postgres you need to connect as the initial user that was set up when you configured your database cluster (usually this user is called
postgres
orpgsql
- or the same name as the (operating system) user that the Postgres daemon runs under) and create some more users (like one for your OS userlarson
).By default
psql
tries to connect with a DB user name that is the same as the OS user name launching the application.Something like
psql -U pgsql .... [database name]
will probably get you in.This is your second question on very basic postgres fundamentals. You REALLY need to spend some quality time with the documentation.
You should read ALL of it, but if that's too daunting at least read (and follow along with) all of Chapter 1, a very excellent tutorial.
I'm absolutely 100% serious about this. The PostgreSQL project is the gold standard by which I judge every other open source project's documentation - It is above the quality of many commercial systems, and really does tell you everything you need to know about setting up and administering a Postgres server.
Go read it now. The server will still be there when you get back, I promise.
(FYI this exact error:
FATAL: role "...." does not exist
is mentioned in the tutorial, along with more detailed instructions on how to log in to Postgres the first time and/or create more users).