安装
官网教程:https://www.postgresql.org/download/linux/redhat/
问题
通过官网教程安装后systemctl start postgresql.service
启动postgreSQL时报错:
Job for postgresql.service failed because the control process exited with error code. See "systemctl status postgresql.service" and "journalctl -xe" for details.
查看错误详情
"/var/lib/pgsql/data" is missing or empty.
Use "postgresql-setup initdb" to initialize the database cluster.
See /usr/share/doc/postgresql-9.2.24/README.rpm-dist for more info
Failed to start PostgreSQL database server.
可以看出是因为没有初始化数据库,但是在启动postgreSQL之前已经我已经执行了postgresql-setup --initdb
,浏览了网上的解决方案发现可能是因为目录权限的问题
chmod 777 /usr/lib/systemd/system/postgresql.service
chmod 777 /usr/bin/postgresql-setup
直接给他们最高权限,然后再执行postgresql-setup --initdb
和systemctl start postgresql.service
后正常启动了。