gpt4 book ai didi

ruby-on-rails - 没有这样的文件或目录服务器是否在本地运行并接受 Unix 域套接字 "/tmp/.s.PGSQL.5432"上的连接?

转载 作者:搜寻专家 更新时间:2023-10-30 23:43:34 24 4
gpt4 key购买 nike

我正在开发一个 Rails4 应用程序。

我的一位同事最近将我们使用的数据库更改为 postgress。当我拉出他的分支并尝试运行我的服务器时,出现以下错误:

could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

这是我的database.yml

default: &default
adapter: postgresql
encoding: unicode
pool: 5

development:
<<: *default
database: sciencevest_development

test:
<<: *default
database: sciencevest_test

production:
<<: *default
database: sciencevest_production
username: sciencevest
password: <%= ENV['SCIENCEVEST_DATABASE_PASSWORD'] %>

gem 文件:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.2'
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Bootstrap & sass
gem 'bootstrap-sass', '~> 3.3.5'
gem 'sass-rails', '>= 3.2'


# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# authentication
gem 'devise'
gem 'devise_invitable'

# authorization
gem 'pundit'

# roles
gem 'rolify'

# states
gem 'aasm'
# pretty development data
gem 'faker'

# uploading images & videos
gem 'carrierwave'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

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

source 'https://rails-assets.org' do
gem 'rails-assets-bootstrap'
end

group :development, :test do

# test suite
gem 'minitest-rails'
gem 'factory_girl_rails', '4.0'

# guards
gem 'guard'
gem 'guard-minitest'
gem 'database_cleaner'

# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'

# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end

group :development do

gem 'guard-livereload'
end

当我运行 ps auwwx|grep postg 时,我得到了这个:

c5227806        42095   0.0  0.0  2432772    648 s001  S+    5:47PM   0:00.00 grep postg

我也有这个:

$ psql --version
psql (PostgreSQL) 9.4.4

还有这个(我不知道它们是否不同):

$ postgres -V
postgres (PostgreSQL) 9.4.4

还有这个:

$ brew info postgres
postgresql: stable 9.4.4 (bottled)
Object-relational database system
https://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.4.4 (3014 files, 40M) *
Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/postgresql.rb
==> Dependencies
Required: openssl ✔, readline ✔
==> Options
--32-bit
Build 32-bit only
--with-dtrace
Build with DTrace support
--with-python
Build with python support
--without-perl
Build without Perl support
--without-tcl
Build without Tcl support
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/Homebrew/homebrew/issues/2510

To migrate existing data from a previous major version (pre-9.4) of PostgreSQL, see:
https://www.postgresql.org/docs/9.4/static/upgrading.html


To have launchd start postgresql at login:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
postgres -D /usr/local/var/postgres
c5227806 at PALM00566449A in ~/desktop/dev_projects/rails_projects/sciencevest on carrierwave
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
/Users/c5227806/Library/LaunchAgents/homebrew.mxcl.postgresql.plist: No such file or directory

有什么想法吗?我在网上找到的所有解释要么不起作用,要么太复杂难以理解。

最佳答案

pg 没有按照我必须运行的评论中所述运行:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

然后创建并迁移数据库。希望这对某人有帮助!

关于ruby-on-rails - 没有这样的文件或目录服务器是否在本地运行并接受 Unix 域套接字 "/tmp/.s.PGSQL.5432"上的连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32030824/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com