code

PostgreSQL 오류 : 치명적 : "사용자 이름"역할이 없습니다.

codestyles 2020. 10. 2. 22:20
반응형

PostgreSQL 오류 : 치명적 : "사용자 이름"역할이 없습니다.


PostgreSQL 9.1을 설정하고 있습니다. PostgreSQL로는 아무것도 할 수 없습니다 : ca n't createdb, ca n't createuser; 모든 작업은 오류 메시지를 반환합니다.

Fatal: role h9uest does not exist

h9uest내 계정 이름 sudo apt-get install이고이 계정으로 PostgreSQL 9.1입니다. 계정에
대해 유사한 오류가 지속 root됩니다.


사용하는 운영 체제 사용자 postgres 데이터베이스를 생성 - 한 당신은 설정하지 않은으로 데이터베이스 에 필요한 권한을 가진 역할을하는 (같은 이름의 운영 체제 사용자에 해당하는 h9uest사용자의 경우) :

sudo -u postgres -i

여기 또는 여기에서 권장 합니다 .

그런 다음 다시 시도하십시오. exit시스템 사용자로 운영이 완료되면 입력하십시오 postgres.

또는 하나의 명령을 실행 createuser으로 postgressudo같이, DREES에 의해 입증 다른 대답한다.

요점은 동일한 이름의 데이터베이스 역할과 일치하는 운영 체제 사용자를 사용하여 ident인증을 통해 액세스 권한을 부여하는 것 입니다. postgres데이터베이스 클러스터를 초기화 한 기본 운영 체제 사용자입니다. 매뉴얼 :

데이터베이스 시스템을 부트 스트랩하기 위해 새로 초기화 된 시스템에는 항상 하나의 사전 정의 된 역할이 포함됩니다. 이 역할은 항상 "수퍼 유저"이며 기본적으로 (를 실행할 때 변경하지 않는 한 initdb) 데이터베이스 클러스터를 초기화 한 운영 체제 사용자와 동일한 이름을 갖습니다. 일반적으로이 역할의 이름은으로 지정 postgres됩니다. 더 많은 역할을 생성하려면 먼저이 초기 역할로 연결해야합니다.

비표준 사용자 이름을 사용하거나 운영 체제 사용자가 존재하지 않는 이상한 설정에 대해 들었습니다. 거기에서 전략을 조정해야합니다.

매뉴얼에서 데이터베이스 역할클라이언트 인증대해 읽으십시오 .


다른 많은 사람들의 솔루션을 시도한 후 성공하지 못한이 답변은 마침내 저를 도왔습니다.

https://stackoverflow.com/a/16974197/2433309

간단히 말해서 달리기

sudo -u postgres createuser owning_user

이름이 owning_user (이 경우 h9uest) 인 역할을 생성합니다. 그 후에 rake db:create는 postgres 환경에 들어 가지 않고도 설정 한 계정 이름으로 터미널에서 실행할 수 있습니다.


sudo su - postgres

psql template1

"superuser"권한으로 pgsql에 역할 생성

CREATE ROLE username superuser;
eg. CREATE ROLE demo superuser;

그런 다음 사용자를 만듭니다.

CREATE USER username; 
eg. CREATE USER demo;

사용자에게 권한 할당

GRANT ROOT TO username;

그런 다음 해당 사용자 로그인을 활성화하면 psql template1일반 $터미널 에서 예 :를 실행할 수 있습니다 .

ALTER ROLE username WITH LOGIN;

를 사용하여 postgres를 설치 apt-get하면 사용자 역할이나 데이터베이스가 생성되지 않습니다.

개인 사용자 계정에 대한 수퍼 유저 역할 및 데이터베이스를 생성하려면 :

sudo -u postgres createuser -s $(whoami); createdb $(whoami)


이것은 나를 위해 작동합니다.

psql -h localhost -U postgres

작업 방법,

  1. vi /etc/postgresql/9.3/main/pg_hba.conf
  2. local all postgres peer여기 피어신뢰로 변경
  3. 재시작, sudo service postgresql restart

  4. 이제 시도해보십시오. psql -U postgres


Postgres 9.5 버전의 경우 다음 명령을 사용하십시오.

psql -h localhost -U postgres

이것이 도움이되기를 바랍니다.


In local user prompt, not root user prompt, type

sudo -u postgres createuser <local username>

Then enter password for local user.

Then enter the previous command that generated "role 'username' does not exist."

Above steps solved the problem for me. If not, please send terminal messages for above steps.


I installed it on macOS and had to:

cd /Applications/Postgres.app/Contents/Versions/9.5/bin
createuser -U postgres -s YOURUSERNAME
createdb YOURUSERNAME

Here's the source: https://github.com/PostgresApp/PostgresApp/issues/313#issuecomment-192461641


Manually creating a DB cluster solved it in my case.

For some reason, when I installed postgres, the "initial DB" wasn't created. Executing initdb did the trick for me.

This solution is provided in the PostgreSQL Wiki - First steps:

initdb

Typically installing postgres to your OS creates an "initial DB" and starts the postgres server daemon running. If not then you'll need to run initdb


psql postgres

postgres=# CREATE ROLE username superuser;
postgres=# ALTER ROLE username WITH LOGIN;

Follow These Steps and it Will Work For You :

  1. run msfconsole
  2. type db_console
  3. some information will be shown to you chose the information who tell you to make: db_connect user:pass@host:port.../database sorry I don't remember it but it's like this one then replace the user and the password and the host and the database with the information included in the database.yml in the emplacement: /usr/share/metasploit-framework/config
  4. you will see. rebuilding the model cache in the background.
  5. Type apt-get update && apt-get upgrade after the update restart the terminal and lunch msfconsole and it works you can check that by typing in msfconsole: msf>db_status you will see that it's connected.

For Windows users : psql -U postgres

You should see then the command-line interface to PostgreSQL: postgres=#


dump and restore with --no-owner --no-privileges flags

e.g.

dump - pg_dump --no-owner --no-privileges --format=c --dbname=postgres://userpass:username@postgres:5432/schemaname > /tmp/full.dump

restore - pg_restore --no-owner --no-privileges --format=c --dbname=postgres://userpass:username@postgres:5432/schemaname /tmp/full.dump

참고URL : https://stackoverflow.com/questions/11919391/postgresql-error-fatal-role-username-does-not-exist

반응형