ruby-on-rails - 在 Ubuntu 上为 WSL 配置 postgresql 到 rails 时遇到问题
问题描述
所以我在 Ubuntu 上为 WSL 使用 VS 代码并从 GitHub 分叉一个 rails 应用程序,当我尝试运行时rails db:set up
,它给了我这个错误:
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"?
Couldn't create 'development_database' database. Please check your configuration.
rails aborted!
ActiveRecord::NoDatabaseError: 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"?
...traces...
Caused by:
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"?
我试着跑service postgresql status
,我得到了10/main (port 5432): down
。
当我尝试时dpkg -l | grep postgres
,我得到了这个:
ii postgresql 10+190ubuntu0.1 all object-relational SQL database (supported version)
ii postgresql-10 10.10-0ubuntu0.18.04.1 amd64 object-relational SQL database, version 10 server
ii postgresql-client 10+190ubuntu0.1 all front-end programs for PostgreSQL (supported version)
ii postgresql-client-10 10.10-0ubuntu0.18.04.1 amd64 front-end programs for PostgreSQL 10
ii postgresql-client-common 190ubuntu0.1 all manager for multiple PostgreSQL client versions
ii postgresql-common 190ubuntu0.1 all PostgreSQL database-cluster manager
ii postgresql-contrib 10+190ubuntu0.1 all additional facilities for PostgreSQL (supported version)
这是否意味着问题是我的服务器没有运行?我应该怎么做才能运行服务器或创建数据库?
解决方案
这意味着您的服务器已安装但未运行。尝试
service postgresql start
启动服务器。
要检查您的实例是否正在运行,请尝试运行
psql -U postgres -d postgres
除非您弄乱了 HBA 配置,否则应该将您连接到postgres
角色中的本地数据库(默认管理数据库)postgres
。
推荐阅读
- apache-kafka - Kafka Streams:有人可以指出一个完全实现的将消息发送到 DLQ(死信队列)主题的 java 示例
- spring-boot - 无法打开通过 spring rest api 下载的文件
- flutter - 断言失败:第 4774 行第 14 行:'_dependents.isEmpty':不正确
- axapta - 在 Axapta 3.0 中使用代码页 UTF-8 保存文本文件
- python - 在 USB 端口上读取串行通信时接收空数据 - Raspberry Pi 3 型号 B+
- swift - 奇怪的模糊 SKShapeNode
- mysql - MySQL 一次查询中的多个计数,带大小写
- jenkins - 无法在从机上使用参数安排 jenkins 构建
- angular - 使用 HostListener 和 Directive 的 ionic 4 angular 8 验证适用于所有表单控件
- excel - 在两张纸之间匹配数据并复制到位置