[DB] POSTGRESQL

[PostgreSQL] SQL 파일 실행

mewoni 2020. 6. 26. 14:50
반응형

postgres 계정에서 실행합니다. 

 

[root@localhost ~]$ su - postgres
비밀번호 입력 : 
[postgres@localhost ~]$

 

[postgres@localhost ~]$ psql -U postgres -d postgres -a -f /var/lib/pgsql/11/database.sql

psql -U [database_user] -d [database_name] -a -f [sql file 절대경로]

 

* postgres 계정으로 실행하면 관리자 권한이 없어 파일이 검색되지 않거나 찾지 못하는 경우가 많으니 postgres가 소유권을 가진 폴더로 sql 파일을 이동시켜 놓은 후 pwd로 정확한 현재 경로 확인해서 psql 명령어 실행하는게 간편하고 빠릅니다.

반응형