![无法启动 postgres,除非我输入命令来重新启动它](https://linux22.com/image/142696/%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8%20postgres%EF%BC%8C%E9%99%A4%E9%9D%9E%E6%88%91%E8%BE%93%E5%85%A5%E5%91%BD%E4%BB%A4%E6%9D%A5%E9%87%8D%E6%96%B0%E5%90%AF%E5%8A%A8%E5%AE%83.png)
每当我尝试启动我的项目时,都会发生以下错误。
django.db.utils.OperationalError: 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的状态:
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; disabled; vendor preset: enabled)
Active: inactive (dead)
而且只有重启服务才起作用,如何避免每次开机都要重启,难道是安装错误了?
我使用的是Ubuntu 18
答案1
您显示的输出systemctl status postgresql
表明它已“禁用”,这意味着它默认情况下不会启动:
已加载:已加载(/lib/systemd/system/postgresql.service;残疾人;
启用该服务以使其在启动时启动:
sudo systemctl enable postgresql