如何停止 postgresql 以释放端口 5432

如何停止 postgresql 以释放端口 5432

我正在尝试运行此命令来为 python Flask 安装 wsgi:

sudo apt-get install libapache2-mod-wsgi-py3

我收到此错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
libapache2-mod-wsgi-py3 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] yes
Setting up postgresql-common (190.pgdg14.04+1) ...
 * Starting PostgreSQL 9.5 database server                                                                       * Error: Port conflict: another instance is already running on /var/run/postgresql with port 5432
                                                                                                         [fail]
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: error processing package postgresql-common (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of postgresql-9.5:
 postgresql-9.5 depends on postgresql-common (>= 158~); however:
  Package postgresql-common is not configured yet.

dpkg: error processing package postgresql-9.5 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of postgresql-contrib-9.5:
 postgresql-contrib-9.5 depends on postgresql-9.5 (= 9.5.12-1.pgdg14.04+1); however:
  Package postgresql-9.5 is not configured yet.

dpkg: error processing package postgresql-contrib-9.5 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                    Errors were encountered while processing:
 postgresql-common
 postgresql-9.5
 postgresql-contrib-9.5
E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试了很多解决方案来停止 postgres,例如:

sudo /etc/init.d/postgresql stop

2.

update-rc.d postresql off

3.

chconfig postresql off

4.

netstat -ntulp|grep 5432

5.

sudo service postgresql stop

所有命令都显示我能够停止 postgresql,但是当我再次运行命令来安装 wsgi 时,它再次出现同样的错误!!!

相关内容