[英]Postgres could not connect to database postgres: could not connect to server: No such file or directory?
我正在使用4.14.10-2-MANJARO。 我试图安装Postgres数据库。 我已经使用命令安装了postgresql 10.1-1:
yaourt -S postgresql
接着:
sudo -u postgres -i
initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data'
createuser --interactive
然后我得到了这样的东西:
createuser: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/run/postgresql/.s.PGSQL.5432"?
我不知道该怎么解决。 我一直在使用这个网站:
https://wiki.archlinux.org/index.php/PostgreSQL#Installing_PostgreSQL
然后,我想通过命令创建一个新的数据库:
createdb myDatabaseName
谢谢。
使用initdb
创建数据目录后,需要使用以下命令启动数据库服务器进程
pg_ctl -D /var/lib/postgres/data start
但是在此之前,您应该编辑/var/lib/postgres/data.postgresql.conf
并设置诸如listen_addresses
, port
, shared_buffers
类的参数以及所有与日志记录有关的参数。
这样,您可以在启动服务器后查阅日志文件,以查看一切是否正常。
我有同样的问题,我也正在运行4.19.1-1-MANJARO
和postgresql 10.5-3
,但是大多数答案是针对Ubuntu的,并且指的是Manjaro上不存在的目录。
您必须运行systemctl来检查服务以查看问题所在
sudo systemctl status postgresql
它给出了这样的东西
systemd[1]: Starting PostgreSQL database server...
postgres[3902]: "/var/lib/postgres/data" is missing >
postgres[3902]: su - postgres -c "initdb --locale >
并告诉您运行上面列出的su
命令。 但这需要用户postgres
的密码。 为了解决这个问题,我们改为使用sudo
命令。
sudo su - postgres -c "initdb --locale en_US.UTF-8 -D /var/lib/postgres/data'"
完成此命令后,它会告诉您运行pg_ctl -D /var/lib/postgres/data start
,而是通过systemctl来启动它。
sudo systemctl enable postgresql
sudo systemctl start postgresql
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.