简体   繁体   English

Postgresql不适用于ubuntu 16.04

[英]Postgresql won't work on ubuntu 16.04

I have installed postgresql 9.5.13, but it seems not to work. 我已经安装了postgresql 9.5.13,但它似乎无法正常工作。 I get continiosly this message: 我不断得到这条消息:

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"? createuser:无法连接到数据库postgres:无法连接到服务器:没有这样的文件或目录服务器是否在本地运行并接受Unix域套接字“/var/run/postgresql/.s.PGSQL.5432”上的连接?

when i try to create user. 当我尝试创建用户时。 I have seen that this is common problem, but i can't find solution for this. 我已经看到这是常见问题,但我无法找到解决方案。

See if the service is running 查看该服务是否正在运行

systemctl status postgresql

If PostgreSQL is running, you'll see output that includes the text Active: active (exited). 如果PostgreSQL正在运行,您将看到包含文本Active:active(exited)的输出。

If you see Active: inactive (dead), start the PostgreSQL service using the following command: 如果您看到Active:inactive(dead),请使用以下命令启动PostgreSQL服务:

systemctl start postgresql

PostgreSQL also needs to be enabled to start on reboot. 还需要启用PostgreSQL才能重启。 Do that with this command: 使用此命令执行此操作:

systemctl enable postgresql

Run

pg_lsclusters

Ver Cluster Port Status Owner    Data directory               Log file
9.5 main 5433 online postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
Status - online - fine

Start the server using the default database path by typing this : 键入以下命令,使用默认数据库路径启动服务器:

sudo -i -u postgres

/usr/lib/postgresql/9.5/bin/pg_ctl -D /var/lib/postgresql/9.5/main/ -l logfile start

than try: 比尝试:

psql

Done ! 做完了!

Due to comments - you need to run the database process - take a look at the documentation 由于注释 - 您需要运行数据库进程 - 请查看文档


In a nutshell it should be something like 简而言之,它应该是类似的东西

    postgres -D /usr/local/pgsql/data >logfile 2>&1 &

depending on what log file you want to create 取决于您要创建的日志文件

One thing I discovered to get this to work is to: 我发现让这个工作的一件事是:

sudo chmod 777 /var/run/postgresql

and then restart like in the above comments. 然后像上面的评论一样重新启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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