반응형
postgresql에서 DB에 대한 사용자를 만드는 방법은 무엇입니까? [닫은]
CentOS 서버에 PostgreSQL 8.4를 설치하고 셸에서 루트 사용자에게 연결하고 PostgreSQL 셸에 액세스했습니다.
PostgreSQL에서 데이터베이스와 사용자를 만들었습니다.
PHP 스크립트에서 연결을 시도하는 동안 인증이 실패했음을 표시합니다.
새 사용자를 생성하고 특정 DB에 대한 권한을 부여하는 방법은 무엇입니까?
CLI에서 :
$ su - postgres
$ psql template1
template1=# CREATE USER tester WITH PASSWORD 'test_password';
template1=# GRANT ALL PRIVILEGES ON DATABASE "test_database" to tester;
template1=# \q
PHP (localhost에서 테스트 한대로 예상대로 작동) :
$connString = 'port=5432 dbname=test_database user=tester password=test_password';
$connHandler = pg_connect($connString);
echo 'Connected to '.pg_dbname($connHandler);
비밀번호를 사용하여 사용자를 작성하십시오.
http://www.postgresql.org/docs/current/static/sql-createuser.html
CREATE USER name [ [ WITH ] option [ ... ] ]
where option can be:
SUPERUSER | NOSUPERUSER
| CREATEDB | NOCREATEDB
| CREATEROLE | NOCREATEROLE
| CREATEUSER | NOCREATEUSER
| INHERIT | NOINHERIT
| LOGIN | NOLOGIN
| REPLICATION | NOREPLICATION
| CONNECTION LIMIT connlimit
| [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
| VALID UNTIL 'timestamp'
| IN ROLE role_name [, ...]
| IN GROUP role_name [, ...]
| ROLE role_name [, ...]
| ADMIN role_name [, ...]
| USER role_name [, ...]
| SYSID uid
그런 다음 특정 데이터베이스에 대한 사용자 권한을 부여하십시오.
http://www.postgresql.org/docs/current/static/sql-grant.html
예 :
grant all privileges on database db_name to someuser;
참고 URL : https://stackoverflow.com/questions/10861260/how-to-create-user-for-a-db-in-postgresql
반응형
'Programming' 카테고리의 다른 글
Python에서 Pandas와 NumPy + SciPy의 차이점은 무엇입니까? (0) | 2020.05.15 |
---|---|
Swift에서 유형이 지정된 배열을 어떻게 확장 할 수 있습니까? (0) | 2020.05.15 |
레일 : dependent => : destroy VS : dependent => : delete_all (0) | 2020.05.15 |
특정 시점에 할당 된 문제를 찾는 방법은 무엇입니까? (0) | 2020.05.15 |
window.location.href = window.location.href와 window.location.reload ()의 차이점 (0) | 2020.05.15 |