简体   繁体   中英

Postgresql: could not connect to server: No such file or directory

Ubuntu 14 I install postgresql server on remote server(digitalocean).

Run command psql and display errors:

postgres@ubuntu-512mb-fra1-01:/home/deploy$ psql
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_PAPER = "be_BY.UTF-8",
    LC_ADDRESS = "be_BY.UTF-8",
    LC_MONETARY = "be_BY.UTF-8",
    LC_NUMERIC = "be_BY.UTF-8",
    LC_TELEPHONE = "be_BY.UTF-8",
    LC_IDENTIFICATION = "be_BY.UTF-8",
    LC_MEASUREMENT = "be_BY.UTF-8",
    LC_TIME = "be_BY.UTF-8",
    LC_NAME = "be_BY.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
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"?

I want reload postgresql server, run command service postgresql start --force

* No PostgreSQL clusters exist; see "man pg_createcluster" 

I think problem with locale setting. But how solve this error?

locale warning won't prevent psql from connecting. Read https://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue on this.

No PostgreSQL clusters exist

means that you probably did not create a cluster. Run smth like pg_createcluster -p 2345 9.5 test to create a test cluster, or better read man pg_createcluster as Ubuntu suggested

Walk this way

  • Find the cluster

     pg_lsclusters 
  • Drop your cluster (Use the information from above)

     pg_dropcluster --stop 9.3 main 
  • Create the cluster anew

     pg_createcluster --locale en_US.UTF-8 --start 9.3 main 
  • Login to postgres

     sudo -u postgres psql 
  • And check locales

     show LC_COLLATE; show LC_CTYPE; 
  • -

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM