PostgreSQL
Postgres 시작하기
Daniel007
2020. 3. 20. 17:37
[root@localhost ~]# su - postgres
마지막 로그인: 일 10월 6 23:36:35 KST 2019 일시 pts/1
-bash-4.2$ psql -U daniel -d test
Password for user daniel:
psql (10.10)
Type "help" for help.
test=#
postgresql 위치 확인
which psql
DB 연결
sudo -u postgres psql
DB 연결 끊기, postgresql 쉘에서 빠져나가기
\q
\? 여러가지 help를 볼수 있음
- 리눅스 postgres 계정의 패스워드 설정
[root@localhost ~]# passwd postgres
패스워드 입력
[root@localhost ~]# su - postgres
마지막 로그인: 일 10월 6 22:14:18 KST 2019 일시 pts/1
-bash-4.2$ psql
psql (10.10)
Type "help" for help.
- postgres DB 안에서 패스워드 설정
postgres=# \password postgres
패스워드 입력
postergresql 유저 생성
##postgres 계정의 홈
-bash-4.2$ createuser daniel --interactive
Shall the new role be a superuser? (y/n) y
-bash-4.2$
-bash-4.2$ psql
psql (10.10)
Type "help" for help.
##user 패스워드 설정
postgres=# \password daniel
Enter new password:
Enter it again:
postgres=#
postgres=# create database danieldb owner daniel ENCODING 'utf-8';
CREATE DATABASE
postgres=# \c danieldb
You are now connected to database "danieldb" as user "postgres".
danieldb=# \c danieldb daniel
FATAL: Peer authentication failed for user "daniel"
Previous connection kept
danieldb=#