CentOS 下 PostgreSQL 报错的原因非常多,不能单凭“报错”两个字定位问题。下面先给你一份常见原因速查清单,你再对照你的具体报错信息来排查。
报错示例
failed to start PostgreSQL
could not create lock file
常见原因
postgresql-setup initdb
postgres 用户)chown -R postgres:postgres /var/lib/pgsql
setenforce 0 # 临时关闭测试
报错
could not connect to server: No such file or directory
connection refused
原因
systemctl start postgresql
postgresql.conf)listen_addresses = 'localhost'
netstat -tnlp | grep postgres
报错
password authentication failed for user "postgres"
原因
pg_hba.conf 配置问题su - postgres
psql -c "ALTER USER postgres PASSWORD 'newpass';"
dnf,且默认 module 可能冲突建议
dnf module disable postgresql
dnf install postgresql-server
df -h
free -m
请把下面信息贴出来,我可以直接帮你定位:
cat /etc/redhat-release
psql --version
CentOS 上 PostgreSQL 报错,90% 是:没初始化、权限错、SELinux、pg_hba.conf、服务没起。
你可以直接把报错贴出来,我按你的实际情况给你一步步命令级解决方案。