当前位置: 首页 > 知识库问答 >
问题:

PostgreSQL无法连接到服务器:没有这样的文件或目录

羊禄
2023-03-14

无法连接到服务器:没有这样的文件或目录,服务器是否在本地运行并接受Unix域套接字“/var/run/PostgreSQL/.s.pgsql.5432”上的连接?

    $ sudo -i -u postgres
    $ psql
     psql: 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"?


    $psql -V 
     psql (PostgreSQL) 11.0 (Ubuntu 11.0-1.pgdg14.04+2)

    $pg_config --version
      PostgreSQL 11.0 (Ubuntu 11.0-1.pgdg14.04+2)

    $postgres -V
     The program 'postgres' is currently not installed. You can install it by typing:
     apt-get install postgres-xc

   $locate bin/postgres
    /usr/lib/postgresql/11/bin/postgres
    /usr/lib/postgresql/9.3/bin/postgres
    /usr/lib/postgresql/9.4/bin/postgres
    /usr/lib/postgresql/9.5/bin/postgres

  $/usr/lib/postgresql/11/bin/postgres -V
    postgres (PostgreSQL) 11.0 (Ubuntu 11.0-1.pgdg14.04+2)

  $pg_lsclusters
  9.3 main    5432 down   postgres /var/lib/postgresql/9.3/main /var/log/postgresql/postgresql-9.3-main.log
  11  main    5433 down   postgres /var/lib/postgresql/11/main  /var/log/postgresql/postgresql-11-main.log

postgres状态已下降

 $service postgresql status
 9.3/main (port 5432): down
 11/main (port 5433): down

 $systemctl status postgresql.service

  postgresql.service
  Loaded: error (Reason: No such file or directory)
 Active: inactive (dead)

 $systemctl status postgresql@9.3-main.service

   postgresql@9.3-main.service
   Loaded: error (Reason: No such file or directory)
   Active: inactive (dead)

$grep-h'^port'/etc/PostgreSQL/*/main/PostgreSQL L.conf/etc/PostgreSQL/11/main/PostgreSQL L.conf:port=5433
/etc/PostgreSQL/9.3/main/PostgreSQL L.conf:port=5432

 $service postgresql start 9.3
    * Starting PostgreSQL 9.3 database server                                                                                          
    * Failed to issue method call: Unit postgresql@9.3-main.service failed 
     to load: No such file or directory. See system logs and 'systemctl 
     status postgresql@9.3-main.service' for details.


  $sudo systemctl start postgresql
   Failed to issue method call: Unit postgresql.service failed to load: No 
   such file or directory. See system logs and 'systemctl status 
    postgresql.service' for details.


   $/etc/init.d/postgresql start
    * Starting PostgreSQL 11 database server                                                                                           
    * Failed to issue method call: Unit postgresql@11-main.service failed to 
    load: No such file or directory. See system logs and 'systemctl status 
    postgresql@11-main.service' for details.

    [fail]
   * Starting PostgreSQL 9.3 database server                                                                                          
   * Failed to issue method call: Unit postgresql@9.3-main.service failed to 
    load: No such file or directory. See system logs and 'systemctl status 
    postgresql@9.3-main.service' for details.
    [fail]

共有1个答案

沃念
2023-03-14

看起来您的postgresql 11运行在port=5433,所以您需要更改PGPORT env变量

导出pgport=5433

 类似资料: