我想从 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
最佳答案
只需在终端中运行此命令:
$ cd /usr/local/var/postgres/
$ rm postmaster.pid
这是因为上次关闭计算机时,Postgresql 没有正常退出(通常是由于电池电量耗尽)。
关于mysql - 从 mysql 转换到 postgres 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41200433/