Createuser: could not connect to database postgres: FATAL: role “tom” does not exist

后端 未结 9 1227
醉话见心
醉话见心 2020-12-04 06:16

I\'m trying to set up Postgres for the first time, and I need to create a user with permissions to read and create databases. However, when I use:

createuser          


        
9条回答
  •  借酒劲吻你
    2020-12-04 06:33

    You mentioned Ubuntu so I'm going to guess you installed the PostgreSQL packages from Ubuntu through apt.

    If so, the postgres PostgreSQL user account already exists and is configured to be accessible via peer authentication for unix sockets in pg_hba.conf. You get to it by running commands as the postgres unix user, eg:

    sudo -u postgres createuser owning_user
    sudo -u postgres createdb -O owning_user dbname
    

    This is all in the Ubuntu PostgreSQL documentation that's the first Google hit for "Ubuntu PostgreSQL" and is covered in numerous Stack Overflow questions.

    (You've made this question a lot harder to answer by omitting details like the OS and version you're on, how you installed PostgreSQL, etc.)

提交回复
热议问题