2014-04-11 2 views
0

백업에서 데이터베이스를 복원하려고하는데 postgresql에 연결할 수 없습니다.psql : FATAL : "expman"사용자의 피어 인증에 실패했습니다.

namespace :db do 
    task import: :environment do 
    import_path = "~/backups" 
    sql_file = "PostgreSQL.sql" 
    database_config = Rails.configuration.database_configuration[Rails.env] 

    system "psql --username=#{database_config['username']} -no-password # {database_config['database']} < #{import_path}/#{sql_file}" 
    end 
end 

pg_hba.conf 파일 (피어 - md5)을 변경해 보았습니다. 콘솔에서 수퍼 유저 postgres과 같은 것을 시도했지만 여전히 실패합니다.

사람들은 데이터베이스를 복원하는 더 좋은 방법을 알고 있습니까? 나는 백업 보석을 사용했다.

편집 : postgresql 서버를 다시 시작하고 인증을 통과했습니다. 그러나, db를 복구하지 못했습니다. 파일의 변경 사항을 되돌리고 -h localhost를 psql 명령에 추가했습니다. 데이터베이스가 지금 복원됩니다. 지금 얻을 수있는 유일한 오류는 다음과 같습니다

must be owner of extension plpgsql //and 
no privileges could be revoked for "public" 

답변

1
  1. 이 변경 위해서는 pg_hba.conf 후에는 다시로드 놈이야 또는 전자 메일 관리자 PID에 SIGHUP 신호를 보냅니다. 그래서 그 변화가 적용되었습니다.
  2. 왜 psql -f를 사용하여 백업 sql 파일을 실행하지 않습니까?
  3. 또는 pg_dump backup 및 pg_restore restore를 사용할 수 있습니다. 또는 복사 명령 백업 및 복원. LIKE :

    digoal=# copy tbl_join_1 to '/home/pg93/tbl_join_1.dmp'; 
    COPY 10 
    digoal=# delete from tbl_join_1; 
    DELETE 10 
    digoal=# copy tbl_join_1 from '/home/pg93/tbl_join_1.dmp'; 
    COPY 10 
    

    또는

    [email protected]> pg_dump -f ./tbl_join_1.dmp -t tbl_join_1 
    [email protected]> psql 
    psql (9.3.3) 
    Type "help" for help. 
    
    digoal=# drop table tbl_join_1; 
    DROP TABLE 
    digoal=# \q 
    [email protected]> psql -f ./tbl_join_1.dmp 
    SET 
    SET 
    SET 
    SET 
    SET 
    SET 
    SET 
    SET 
    SET 
    CREATE TABLE 
    ALTER TABLE 
    ALTER TABLE 
    
+0

감사합니다,하지만 난 백업 보석이 필요합니다. 여기에 내가 가진 것이있다. pg_conf 파일을 변경 한 후 postgresql 프로세스를 다시 시작하는 것을 잊었습니다. 그러나 나는 모든 변경 사항을 지금 되돌리고 심지어 이것으로 뭔가를 얻었습니다 : psql --username = # {database_config [ 'username']} -h localhost # {database_config [ 'database']} <# {import_path}/# {sql_file} 이제 작업을 실행하면 모든 문제가 해결됩니다. 데이터베이스가 복원됩니다. 그러나 화면에 여전히 오류가 거의 없습니다. ""확장자 plpgsql의 소유자 여야합니다 " 및 " "public" " – enter08

관련 문제