【问题标题】:Transition from mysql to postgress error从 mysql 转换到 postgres 错误
【发布时间】:2017-05-03 04:43:36
【问题描述】:

我想从 mysql 更改为 postgresql。 我不关心数据,所以我更改了 database.yml:

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000

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

test:
  <<: *default
  database: db/test.postgresql

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

然后运行

rails db:reset db:migrate

但我得到错误

rails aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

我已经重新启动了 IDE(使用 c9)和服务器,但是没有任何效果。 知道如何解决这个问题吗?

@Edit 运行sudo service postgresql start 后服务器启动,然后当我运行rails db:create

我得到错误:

psql: FATAL:  role "ubuntu" does not exist

【问题讨论】:

  • postgres 服务器没有运行。如果您使用的是 Mac,请使用 postgresapp.com 在本地下载、安装和运行 Postgres。
  • 检查postgres服务是否正在运行,如果是不同的电脑检查端口和防火墙
  • 您是否安装了正确的 gem?
  • 伙计们,正如我所说,我正在使用 C9。我认为它适用于ubuntu。你说的这些我都做不了。
  • 我已经安装了 gem 'pg', '0.19.0'

标签: mysql ruby-on-rails ruby database postgresql


【解决方案1】:

只需在终端中运行:

$ cd /usr/local/var/postgres/
$ rm postmaster.pid

这是因为上次您的计算机关闭时,Postgresql 没有正常退出(通常是由于电池没电了)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-02
    • 1970-01-01
    • 1970-01-01
    • 2019-11-29
    • 1970-01-01
    • 1970-01-01
    • 2015-10-07
    • 2021-11-15
    相关资源
    最近更新 更多