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

后端 未结 9 1205
醉话见心
醉话见心 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:41

    If you don't want to change the authentication method (ident) and mess with pg_hba.conf use this:

    First login as the default user

     sudo su - posgres
    

    then access psql and create a user with the same name as the one you are login in

    postgres=# CREATE USER userOS WITH PASSWORD 'garbage' CREATEDB;
    

    you can verify your user with the corresponding roles with

    postgres=#  \du
    

    Afer this you can create your database and verify it with

    psql -d dbName
    \l
    \q
    

提交回复
热议问题