Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axESV-0003gU-0t for pgsql-zh-general@arkaria.postgresql.org; Mon, 02 May 2016 14:04:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1axESU-0000aG-Iz for pgsql-zh-general@arkaria.postgresql.org; Mon, 02 May 2016 14:04:22 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1axESU-0000Zh-5D for pgsql-zh-general@postgresql.org; Mon, 02 May 2016 14:04:22 +0000 Received: from [124.127.160.226] (helo=mail.freemail.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1axERL-00074A-Vp for pgsql-zh-general@postgresql.org; Mon, 02 May 2016 14:04:11 +0000 Received: from [192.168.0.103] (unknown [111.167.157.36]) by mail.freemail.com (Postfix) with ESMTPSA id EA95410080B for ; Mon, 2 May 2016 21:59:44 +0800 (CST) To: "pgsql-zh-general@postgresql.org" From: Quan Zongliang Subject: =?UTF-8?B?5pqX6buR5paH77ya5aaC5L2V56+h5pS5IFBvc3RncmVTUUwg57O757uf?= =?UTF-8?B?5pWw5o2u?= Message-ID: <57275DC7.10109@postgresdata.com> Date: Mon, 2 May 2016 22:01:43 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 124.127.160.226 (failed) X-Pg-Spam-Score: 0.4 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-zh-general Precedence: bulk Sender: pgsql-zh-general-owner@postgresql.org 写这篇文章的目的其实是给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