CSGHub icon indicating copy to clipboard operation
CSGHub copied to clipboard

运行配置数据库bin/rails db:create遇到问题

Open zhaoxinhua opened this issue 1 year ago • 10 comments

操作系统:Ubuntu 1721288884866

已安装:PostgreSQL 并已运行 image

执行配置数据库中的:bin/rails db:create 提示一下错误 06735f2c27461ea5e423c139b52cfa1

zhaoxinhua avatar Jul 18 '24 07:07 zhaoxinhua

@zhaoxinhua 根据信息来看,应该是我们本地 postgres 没有配置免密登录 这是项目的数据库配置,可以看到我们只提供了用户名,没有提供密码 image

一般而言,本地开发我们有两种配置方式

  1. 无密码登录 img_v3_02cc_3dbd3477-b7f2-45e2-ad85-32a2e2f2691g

  2. 密码登录

  • 登录数据库,创建一个初始用户 postgres
  • 为 postgres 用户设置登录密码
  • 然后在项目的 config/database.yml 文件添加 img_v3_02cc_d62d04b7-0718-4df0-a20f-0dbf7449e12g

hiveer avatar Jul 18 '24 08:07 hiveer

@hiveer 您好 image

image 此处改完后,下面重启了服务,并正常运行 image 但是执行创建库 image image

zhaoxinhua avatar Jul 18 '24 09:07 zhaoxinhua

@zhaoxinhua 把你本地的 config/database.yml 贴上来我看下

hiveer avatar Jul 18 '24 09:07 hiveer

@zhaoxinhua 执行下面的两条命令,结果是啥贴上来:

psql -U postgres
\l

hiveer avatar Jul 18 '24 09:07 hiveer

image @hiveer

zhaoxinhua avatar Jul 18 '24 09:07 zhaoxinhua

database.txt @hiveer 我把后缀改成txt才能发到github

zhaoxinhua avatar Jul 18 '24 10:07 zhaoxinhua

database.txt @hiveer 我把后缀改成txt才能发到github

服务数据库的配置没有问题,你的问题出在你的 postgresql 的安装上

psql -U postgres 的命令的提示信息,告诉我们,你的 PG 是连不上的

hiveer avatar Jul 18 '24 10:07 hiveer

@zhaoxinhua 这个问题解决了吗?

hiveer avatar Aug 27 '24 05:08 hiveer