当前位置: 首页 > 知识库问答 >
问题:

Ruby on Rails PG::ConnectionBad

苏磊
2023-03-14

当我运行命令时,我正在尝试部署我的应用程序

rails server -b $IP -p $PORT

提取的源码(第56行附近):

### Convenience alias for PG::Connection.new.
def self::connect( *args )
    return PG::Connection.new( *args )
end

我的database.yml是

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: 5

development:
  <<: *default
  database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3

========更新======

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: 5

development:
  adapter: postgresql
  encoding: unicode
  database: sale_development
  pool: 5

test: &test
  adapter: postgresql
  encoding: unicode
  database: sale_test
  pool: 5

production:
  adapter: postgresql
  encoding: unicode
  database: sale_production
  pool: 5
  host: localhost
  username: sale
  password: <%= ENV['SALE_DATABASE_PASSWORD'] %>
 source 'https://rubygems.org'

 git_source(:github) do |repo_name|
   repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
   "https://github.com/#{repo_name}.git"
 end


 # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
 gem 'rails', '~> 5.1.1'
 # Use sqlite3 as the database for Active Record
 gem 'sqlite3'
 gem 'pg'
 # Use Puma as the app server
 gem 'puma', '~> 3.7'
 # Use SCSS for stylesheets
 gem 'sass-rails', '~> 5.0'
 # Use Uglifier as compressor for JavaScript assets
 gem 'uglifier', '>= 1.3.0'
 # See https://github.com/rails/execjs#readme for more supported runtimes
 # gem 'therubyracer', platforms: :ruby

 # Use CoffeeScript for .coffee assets and views
 gem 'coffee-rails', '~> 4.2'
 # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
 gem 'turbolinks', '~> 5'
 # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'bootstrap-sass'
gem "paperclip", "~> 5.0.0"
gem 'devise', '~> 4.3'
gem 'will_paginate', '~> 3.0'


# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
   # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

共有1个答案

昌招
2023-03-14

我认为它显示了与sqlite3的连接,如果它是生产的,那么你必须输入用户名和密码

如果使用postgresql,这是供您参考的

development:
  adapter: postgresql
  encoding: unicode
  database: your_database_name
  pool: 5

test: &test
  adapter: postgresql
  encoding: unicode
  database: your_database_name_test
  pool: 5

production:
  adapter: postgresql
  encoding: unicode
  database: your_database_name_production
  pool: 5
  host: localhost
  username: some_user_name
  password: some_password
 类似资料:
  • 问题内容: 使用Phusion Passenger运行Rails,目前在postgres遇到问题,每当我运行build命令时,都会出现此错误: 我的Dockerfile pastebin 完整的错误日志 非常感谢您的任何帮助,我仍然掌握Docker并致力于生产。 问题答案: 它试图连接到Unix域套接字的事实指出了Rails应用程序中的配置问题。您已经在其中,但是已将其注释掉了- 至少应该更近地进

  • 运行时,会收到以下错误消息: 致命:用户"rails_dev"的身份验证失败 无法为{"适配器"=创建数据库 PG::ConnectionBad:FATAL:Ident身份验证用户“rails_dev” /home/whitehat/.rvm/gems/ruby-2.4.0/gems/PG-0.21.0/lib/PG.rb:56:in'initialize' /home/whitehat/.rvm

  • 我刚刚将mac OS X更新到Yosemite10.10.4版本,并将postgresql更新到:psql(postgresql)9.4.4。

  • 每次运行Rails4.0服务器时,都会得到这个输出。 我正在运行小牛OS X10.9,所以我不知道这是不是问题所在。我已经试了我能试的一切,但似乎都没有效果。我已经卸载并安装了postgres和pg gem多次了。 这是我的database.yml文件

相关问答

相关文章

相关阅读