替换其数据文件夹中的内容后,PostgreSQL 无法启动

Nyx*_*nyx 4 postgresql ubuntu psql

当从被黑的 Ubuntu 12.04 服务器恢复 Postgresql 数据库时,我将数据目录复制到另一个位置,重新安装操作系统和 PostgreSQL,停止 PostgreSQL 服务,删除数据目录中的内容并从以前的安装中复制回内容。

问题: PostgreSQL 现在无法启动,显示以下错误。为什么会发生这种情况,我们如何解决这个问题?

service postgresql restart
* Restarting PostgreSQL 9.1 database server                                     
Run Code Online (Sandbox Code Playgroud)

* Error: could not exec /usr/lib/postgresql/9.1/bin/pg_ctl /usr/lib/postgresql/9.1/bin/pg_ctl start -D /var/lib/postgresql/9.1/main -l /var/log/postgresql/postgresql-9.1-main.log -s -o -c config_file="/etc/postgresql/9.1/main/postgresql.conf" :


更新

现在重新启动 PostgreSQL 服务会出现错误:

* Restarting PostgreSQL 9.1 database server                                     
* The PostgreSQL server failed to start. Please check the log output:
2013-04-16 01:52:10 EDT PANIC:  could not open control file "global/pg_control": Permission denied
Run Code Online (Sandbox Code Playgroud)

小智 7

我遇到了同样的问题。为了澄清 Nyxynyx 在他的评论中暗示的内容,解决方案是授予访问 db cluster 目录的权限(-D错误中的路径):

chown -R postgres:postgres /var/lib/postgresql/9.1/main
Run Code Online (Sandbox Code Playgroud)