对于Buffalo golang框架,我需要创建一个postgres数据库:
marco@pc01:~/go/src/vuerecipe$ buffalo db create -a
v4.11.1
[POP] 2019/06/17 15:27:09 info - create vuerecipe_development
(postgres://postgres:postgres@127.0.0.1:5432
/vuerecipe_development?sslmode=disable)
Error: couldn't create database vuerecipe_development: error creating
PostgreSQL database vuerecipe_development: dial tcp 127.0.0.1:5432:
connect: connection refused
Usage:
buffalo-pop pop create [flags]
Flags:
-a, --all Creates all of the databases in the database.yml
-h, --help help for create
Global Flags:
-c, --config string The configuration file you would like to use.
-d, --debug Use debug/verbose mode
-e, --env string The environment you want to run migrations
against. Will use $GO_ENV if set. (default "development")
-p, --path string Path to the migrations folder (default
"./migrations")
couldn't create database vuerecipe_development: error creating
PostgreSQL database vuerecipe_development: dial tcp 127.0.0.1:5432:
connect: connection refused
Usage:
buffalo db [flags]
Aliases:
db, db
Flags:
-h, --help help for db
按照此问题的答案中的提示和说明进行操作: Can't connect to Postgresql on port 5432 - StackOverflow
我停止了postgresql服务:
marco@pc01:~/go/src/vuerecipe$ sudo systemctl stop postgresql.service
我修改了/etc/postgres/11/main/postgresql.conf中的listen_addresses:
listen_addresses = '*'
并将以下三行添加到/etc/postgres/qq/main/pg_hba.conf的末尾:
host all all 0.0.0.0/0 md5
host all all ::/0 md5
host all all 192.168.1.7/32 md5
并重新启动postgresql服务:
marco@pc01:~/go/src/vuerecipe$ sudo systemctl start postgresql.service
但是问题仍然存在:
marco@pc01:~/go/src/vuerecipe$ buffalo db create -a
v4.11.1
[POP] 2019/06/17 15:46:39 info - create vuerecipe_development
(postgres://postgres:postgres@127.0.0.1:5432
/vuerecipe_development?sslmode=disable)
Error: couldn't create database vuerecipe_development: error creating
PostgreSQL database vuerecipe_development: dial tcp 127.0.0.1:5432:
connect: connection refused
Usage:
buffalo-pop pop create [flags]
是否有任何提示和建议来解决与PostgreSQL数据库的连接问题?
期待您的帮助。 马可
防火墙处于非活动状态:
marco@pc01:~/go/src/vuerecipe$ sudo ufw status
Status: inactive
已解决:读完这篇文章:https://askubuntu.com/questions/50621/cannot-connect-to-postgresql-on-port-5432之后,我删除了以前的postgres-11安装,然后重新安装。