0

When I write createdb mydb in the bash terminal. I write the password, but I am getting an error for a user "amodhakal". I have not set up that user, so I was wondering how I can change that user to "postgres" so I can use createdb mydb. Thank You for helping. If more clarification is needed, just let me know!

$ createdb mydb Password: Password: createdb: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "amodhakal" 

When I type psql, I get password for user amodhakal. Like I said, that user doesn't exist so I need to delete that user, and change it to "postgres"

psql Password for user amodhakal: 
8
  • Like all postgres utility scripts, createdb takes a -U connection parameter option. Commented Apr 12, 2022 at 20:34
  • I want to be where I can just use createdb without -U like how the invalid user "amodhakal" is Commented Apr 12, 2022 at 20:36
  • Does this answer your question? Create database from command line Commented Apr 12, 2022 at 20:36
  • That's just not how createdb works. It uses the current shell user (OS account) name if you don't specify a username explicitly. Commented Apr 12, 2022 at 20:38
  • 1
    createdb is a libpg based client so you can use environment variables as shown in the Environment section of the createdb link to set the connection parameters. In your case PGUSER. Though this will become the 'default' user for all libpq based clients that are the same environment, unless overridden at the command line. Commented Apr 12, 2022 at 21:14

1 Answer 1

0

createdb is a libpq based client so you can use environment variables as shown in the Environment section of the createdb link to set the connection parameters. In your case PGUSER. Though this will become the 'default' user for all libpq based clients that are the same environment, unless overridden at the command line. For all the libpq environment variables available see libpq env

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.