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



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

我的一个同事最近更改了我们用来提交的数据库。当我拉他的分支并尝试运行我的服务器时,我得到以下错误:

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"?

这是我的数据库。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'] %>

Gemfile:

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

创建和迁移数据库。希望这能帮助到一些人!

相关内容

  • 没有找到相关文章

最新更新