[英]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.