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

时间:2016-12-01 08:19:09

标签: postgresql ubuntu ubuntu-14.04 digital-ocean

Ubuntu 14 我在远程服务器(digitalocean)上安装postgresql服务器。

运行命令psql并显示错误:

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"?

我想重新加载postgresql服务器,运行命令service postgresql start --force

* No PostgreSQL clusters exist; see "man pg_createcluster" 

我认为区域设置有问题。但是如何解决这个错误?

2 个答案:

答案 0 :(得分:0)

区域设置警告无法阻止psql连接。请阅读https://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue

  

不存在PostgreSQL集群

表示您可能没有创建群集。像pg_createcluster -p 2345 9.5 test一样运行smth来创建一个测试集群,或者更好地阅读Ubuntu建议的man pg_createcluster

答案 1 :(得分:0)

走这条路

  • 找到群集

    pg_lsclusters
    
  • 删除群集(使用上面的信息)

    pg_dropcluster --stop 9.3 main
    
  • 重新创建群集

    pg_createcluster --locale en_US.UTF-8 --start 9.3 main
    
  • 登录postgres

    sudo -u postgres psql
    
  • 并检查区域设置

    show LC_COLLATE;
    show LC_CTYPE;
    
  •   -