使用命令启动postgre数据库时,提示如下错误。
pg_ctl -D ..\data -l logfile start
waiting for server to start....Active code page: 65001
stopped waiting
pg_ctl: could not start server
Examine the log output.
查看pgsql\bin\logfile,信息如下
2021-04-15 01:02:00.566 GMT [17832] LOG: could not bind IPv6 address "::1": Permission denied
2021-04-15 01:02:00.566 GMT [17832] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2021-04-15 01:02:00.567 GMT [17832] LOG: could not bind IPv4 address "127.0.0.1": Permission denied
2021-04-15 01:02:00.567 GMT [17832] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2021-04-15 01:02:00.567 GMT [17832] WARNING: could not create listen socket for "localhost"
2021-04-15 01:02:00.567 GMT [17832] FATAL: could not create any TCP/IP sockets
2021-04-15 01:02:00.570 GMT [17832] LOG: database system is shut down
根据日志判断,应该是5432端口被占用。查找被占用端口的进程号,提示如下。
netstat -ano | findstr 5432
TCP 0.0.0.0:5432 0.0.0.0:0 LISTENING 6184
TCP 10.80.78.38:56424 40.90.189.152:443 ESTABLISHED 15432
TCP 10.80.78.38:60569 52.114.76.34:443 ESTABLISHED 15432
TCP [::]:5432 [::]:0 LISTENING 6184
使用命令删掉6184后,
taskkill /F /pid 6184
SUCCESS: The process with PID 6184 has been terminated.
再次启动,则服务正成。