0

After recently setting up Postgresql on my Raspberry Pi I created an account which is not a power user. Initially to set this up I entered

psql

from the terminal and then executed

createuser pi -P --interactive

I responded N for superuser Y for create databases Y for create new roles and then.

Create database test;

When I try to go to psql now using simply

psql

I get

pi@raspberrypi:~ $ psql psql: FATAL:  database "pi" does not exist

I can go to psql test and create databases there, but I was wondering what causes this behavior.

Does terminal automatically pass the Pi user credentials to postgresql or is it logging me in with my system's Pi Account?

  • Creating a user account does NOT create a database for them to use in the same process. createdb -O pi pi and then you should be fine. – tink Apr 2 at 22:28
0

You are not showing the psql command you are attempting to use to connect to your Postgresql server. Though, I can possibly explain what is going on without that information.

If you do not specify a user in your psql command, it tries to use the username you are currently logged in as. If you do not specify a database, it will attempt to load a database of the same name as the user.

The error you are getting is database "pi" does not exist which indicates it could not load the database pi. In your posted question, you mention creating the username pi and the database test. You would want to specify to load the test database in your psql command:

psql --dbname=test

If you were not logged in as the pi user, you would want to pass the username in your psql command:

psql --username=pi --dbname=test

If none of that works, post your psql command in your question and we can get a better idea of what is going on.

  • Thank you. I believe this is the case. I have edited the post to more accurately show what commands I am executing. When I have a chance to experiment with these options, I'll add a follow up comment. Thanks for helping a noob out. – Michael Shoe Apr 4 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.