2012-08-10 115 views
1

我在獲取db:structure:dump工作時遇到問題。pg_dump - 權限被拒絕(db:structure:dump)

我和收到此錯誤:

C:\Sites\care>rake db:structure:dump --trace 
Creating scope :search. Overwriting existing method PgSearch::Document.search. 
** Invoke db:structure:dump (first_time) 
** Invoke environment (first_time) 
** Execute environment 
** Execute db:structure:dump 
rake aborted! 
Permission denied - pg_dump -i -s -x -O -f C:/Sites/care/db/structure.sql care_development 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.1/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.1/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.1/lib/active_record/railties/databases.rake:389:in `block (3 levels) in <top (required)>' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>' 
C:/RailsInstaller/Ruby1.9.3/bin/rake:19:in `load' 
C:/RailsInstaller/Ruby1.9.3/bin/rake:19:in `<main>' 
Tasks: TOP => db:structure:dump 

如果我運行它像這樣在CMD,它的工作原理:

cd C:\Program Files (x86)\PostgreSQL\9.1\bin 
pg_dump.exe -i -s -x -O -f C:/Sites/care/db/structure.sql care_development 

我試圖改變雙方的pg_dump.exe文件夾的權限/文件和rails文件夾/文件。但似乎沒有任何不同。試圖爲用戶,系統甚至每個人添加完整的權限。

我也嘗試在pg_dump調用中添加--username params(在rake代碼中),並在pgAdminIII中添加匹配我windows用戶的登錄角色。

(我在Windows 7中,Rails 3的和PostgreSQL 9)

不要任何人知道這個問題可能是什麼?

回答

0

我有同樣的問題,我的Linux機器上: 然後我用下面的命令,使其運行:

su 

>> I logged in first with my Admin user 

su -postgres 

保存我的.sql文件在我的文件夾/tmp

,傾倒.sql文件在數據庫中運行命令

psql -u postgres -d my_db_name -a -f /tmp/path_to_sql_file 

它對我很有效。希望它可以幫助你。

+0

此外,你可以把你的'structure.sql'放在你的windows臨時文件夾中。 – 2013-04-06 05:41:39