agora inbox for pgsql-zh-general@postgresql.org
help / color / mirror / Atom feedFrom: Quan Zongliang <zongliang.quan@postgresdata.com>
To: pgsql-zh-general@postgresql.org <pgsql-zh-general@postgresql.org>
Subject: 暗黑文:如何篡改 PostgreSQL 系统数据
Date: Mon, 2 May 2016 22:01:43 +0800
Message-ID: <57275DC7.10109@postgresdata.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-zh-general>
写这篇文章的目的其实是给DBA一个修复数据库的途径,希望有用。
此方法可能带来严重后果,请务必谨慎使用。
在清楚自己要做什么的前提下,它可能会带来一些福利,否则恐怕只有老天爷知道
会发生什么,所以请务必谨慎使用。
1、这种操作能力的出处来自 initdb,具体请看 initdb.c 源代码。
static const char *backend_options = "--single -F -O -c
search_path=pg_catalog -c exit_on_error=true";
2、如果我们试图修改 pg_catalog,会收到如下提示
ERROR: permission denied to create "pg_catalog.xxx"
DETAIL: System catalog modifications are currently disallowed.
3、进入具有修改数据库系统表的命令行
./postgres --single -F -O -c search_path=pg_catalog -c
exit_on_error=true -D ../data flying
search_path=pg_catalog 是操作的目标 namespace(也就是外在表现的 schema
自行查阅文档),这就是文档中的 search_path 参数。
exit_on_error=true 遇到错误立即退出
最后一个为数据库名
3、创建 / 修改 / 操作 某个对象
此处请自行想象 ……
4、退出方法
a) 如果我们设置了 search_path=pg_catalog,可以随便输入一个出错的命令即可
结束。
b) 最安全的办法 Ctrl + D
原文地址
http://my.oschina.net/quanzl/blog/668795
--------------------------------------------
权宗亮
--
Sent via pgsql-zh-general mailing list (pgsql-zh-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-zh-general
view thread (11+ messages) latest in thread
Message-ID: <57275DC7.10109@postgresdata.com>
Permalink: ../57275DC7.10109@postgresdata.com/
Also on: postgresql.org/message-id/57275DC7.10109@postgresdata.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-zh-general@postgresql.org
Cc: zongliang.quan@postgresdata.com
Subject: Re: 暗黑文:如何篡改 PostgreSQL 系统数据
In-Reply-To: <57275DC7.10109@postgresdata.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox