0

I have just installed Postgres 12 on a Mac. As you may soon appreciate I am totally new to it.

During the installation process I was asked to provide a "password". I do not remember specifically, but I think it was for the some sort of admin role.

Now I want to create my first database. Reading the documentation I insert the command

createdb myfistdb

the system asks for a password. I give the one I set during the installation processes but I got the following error

createdb: error: could not connect to database template1: FATAL:  password authentication failed for user "myusername"

where myusername is the user I am logged in.

The same happens if I give the system password of myusername.

I understand that my question is pretty basic, but I have been struggling quite some time without any success, so any help will be appreciated.

3
  • Have you tried to reset the password, if yes and it still fails, just restart it and try to login again Commented Oct 13, 2019 at 13:36
  • Try logging in as the postgres user, not the myusername one Commented Oct 13, 2019 at 13:49
  • 1
    You need to provide the DB user name with the -U option. Here are the docs: postgresql.org/docs/current/app-createdb.html Commented Oct 13, 2019 at 15:02

1 Answer 1

2

The database uset name used by createdb defaults to the operating system user name, so you'll have to specify the administrative superuser explicitly:

createdb -U postgres myfistdb
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.