postgresql - PostgreSQL 端口 5432 已在使用 // 忘记用户密码
问题描述
这几天我在使用 postgreSQL 时遇到了一些麻烦(macos 版本:10.15.4)
- 我丢失了用户密码,因此无法登录 psql 控制台
- 我尝试启动 PosgreSQL 12 应用程序以更好地可视化我的数据库,并且不知何故我的端口一直在使用中
我的第一个问题是:
- 如何重置我的所有 postgresql 配置以重新开始并重置用户和密码?(我的数据库中没有重要数据)
我已经尝试
brew uninstall postgresql
过
brew remove postgresql
在那方面没有任何作用
第二个问题和第二种可能性
- 我试图遵循该解决方案中的指示:https ://github.com/dwyl/learn-postgresql/issues/60
启动应用程序时,它告诉我端口 5432 已在使用中
我遇到了一个奇怪的行为:
lsof -i TCP:5432
给了我两行在端口中侦听的进程我试图杀死它工作的相关 pid 但是随后另一个新的 pid 出现并使用端口 5432 并且 pid 号增加,就好像无论发生什么我的 postgres cammand 都重新生成了我的端口5432 正在使用中。
有了这个,我被一个我无法使用的应用程序和一个我无法连接的命令行所困。
您知道如何重置或解决问题吗?
编辑似乎每10秒我的postgre日志文件就会增加这个
2020-04-28 19:28:52.579 CEST [12186] LOG: starting PostgreSQL 12.2 on x86_64-apple-darwin19.4.0, compiled by Apple clang version 11.0.3 (clang-1103.0.32.59), 64-bit
2020-04-28 19:28:52.626 CEST [12186] LOG: could not bind IPv6 address "::1": Address already in use
2020-04-28 19:28:52.626 CEST [12186] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2020-04-28 19:28:52.626 CEST [12186] LOG: could not bind IPv4 address "127.0.0.1": Address already in use
2020-04-28 19:28:52.626 CEST [12186] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2020-04-28 19:28:52.626 CEST [12186] WARNING: could not create listen socket for "localhost"
2020-04-28 19:28:52.626 CEST [12186] FATAL: could not create any TCP/IP sockets
2020-04-28 19:28:52.649 CEST [12186] LOG: database system is shut down
感谢您对此的任何建议!干杯,
解决方案
重新启动计算机后,有时即使端口 5432 上没有运行任何进程,我也会收到端口 5432 已在使用错误。
什么对我有用:
ps -ef | grep postgres
这显示了在 postgres 用户下运行的所有进程。
sudo pkill -u postgres
这会杀死那些进程
推荐阅读
- browser - P5.JS Sketch 不会在浏览器中加载
- python - model_evaluation_utils 混淆矩阵出错
- scala - Spark:对象不可序列化
- python - 为什么我得到退出代码 -1 却没有在 IDE 中显示任何错误?
- python - 如何从 PDF(Python PDFminer)中提取指数?
- reactjs - 未触发 useEffect
- string - Octave 中的函数 strfind() 未在文本文件中找到双换行符
- python - 用 Python 装饰一个类,打印装饰类的 int 变量
- android - 使用 Android 打开蓝牙会使其成为信标吗?
- arrays - 电子表格减少了二维范围内的 JS 类函数?