我按照这篇文章来安装postgres https://gorails.com/setup/ubuntu/15.04
但是我在尝试启动postgresql时出现此错误
vihaan@trojan:~$ sudo -u postgres createuser vihaan -s
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 "/var/run/postgresql/.s.PGSQL.5432"?
以下是来自postgres软件包安装的消息。
vihaan@trojan:~$ sudo apt-get install postgresql-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
dkms libgsoap5 libsdl1.2debian libvncserver0
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
postgresql-client-common
The following NEW packages will be installed:
postgresql-client-common postgresql-common
0 upgraded, 2 newly installed, 0 to remove and 97 not upgraded.
Need to get 0 B/300 kB of archives.
After this operation, 816 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package postgresql-client-common.
(Reading database ... 180173 files and directories currently installed.)
Preparing to unpack .../postgresql-client-common_169.pgdg12.4+1_all.deb ...
Unpacking postgresql-client-common (169.pgdg12.4+1) ...
Selecting previously unselected package postgresql-common.
Preparing to unpack .../postgresql-common_169.pgdg12.4+1_all.deb ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Unpacking postgresql-common (169.pgdg12.4+1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for systemd (219-7ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up postgresql-client-common (169.pgdg12.4+1) ...
Setting up postgresql-common (169.pgdg12.4+1) ...
Creating config file /etc/postgresql-common/createcluster.conf with new version
Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
en_au
en_gb
en_us
en_za
Removing obsolete dictionary files:
Processing triggers for systemd (219-7ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...
vihaan@trojan:~$ sudo apt-get install postgresql-9.3 libpq-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libpq-dev is already the newest version.
The following packages were automatically installed and are no longer required:
dkms libgsoap5 libsdl1.2debian libvncserver0
Use 'apt-get autoremove' to remove them.
Suggested packages:
oidentd ident-server locales-all postgresql-doc-9.3
The following NEW packages will be installed:
postgresql-9.3 postgresql-client-9.3
0 upgraded, 2 newly installed, 0 to remove and 97 not upgraded.
Need to get 0 B/4,497 kB of archives.
After this operation, 21.9 MB of additional disk space will be used.
Selecting previously unselected package postgresql-client-9.3.
(Reading database ... 180293 files and directories currently installed.)
Preparing to unpack .../postgresql-client-9.3_9.3.9-1.pgdg12.4+1_amd64.deb ...
Unpacking postgresql-client-9.3 (9.3.9-1.pgdg12.4+1) ...
Selecting previously unselected package postgresql-9.3.
Preparing to unpack .../postgresql-9.3_9.3.9-1.pgdg12.4+1_amd64.deb ...
Unpacking postgresql-9.3 (9.3.9-1.pgdg12.4+1) ...
Processing triggers for postgresql-common (169.pgdg12.4+1) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
en_au
en_gb
en_us
en_za
Removing obsolete dictionary files:
Setting up postgresql-client-9.3 (9.3.9-1.pgdg12.4+1) ...
update-alternatives: using /usr/share/postgresql/9.3/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-9.3 (9.3.9-1.pgdg12.4+1) ...
Creating new cluster 9.3/main ...
config /etc/postgresql/9.3/main
data /var/lib/postgresql/9.3/main
locale en_IN
Flags of /var/lib/postgresql/9.3/main set as -------------e-C
port 5432
update-alternatives: using /usr/share/postgresql/9.3/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
vihaan@trojan:~$ sudo -u postgres createuser vihaan -s
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 "/var/run/postgresql/.s.PGSQL.5432"?
答案 0 :(得分:2)
您安装了错误的软件包:apt-get install postgresql
或者阅读此tutorial以获取更多信息。
在你提到的帖子中,你可能错过了这个步骤:
sudo apt-get install postgresql-9.3 libpq-dev