Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 在缺乏写入权限的情况下,如何转储postgres拥有的数据_Database_Postgresql_Dump_Pg Dump - Fatal编程技术网

Database 在缺乏写入权限的情况下,如何转储postgres拥有的数据

Database 在缺乏写入权限的情况下,如何转储postgres拥有的数据,database,postgresql,dump,pg-dump,Database,Postgresql,Dump,Pg Dump,我有属于postgres的数据库,我需要转储它,但是postgres用户没有写入权限。 因此,它可以归结为以postgres的身份登录数据库,但在操作系统中的不同用户下。我该怎么做?我尝试了-U postgres,但即使没有密码提示也出现了错误。基本上,我在Postgres中寻找'mysql-u root-p'。转储到标准输出,并让另一个操作系统用户写入该文件 假设您是根用户: # (su postgres -c 'pg_dump -U postgres dbname') > /path/

我有属于
postgres
的数据库,我需要转储它,但是
postgres
用户没有写入权限。
因此,它可以归结为以
postgres
的身份登录数据库,但在操作系统中的不同用户下。我该怎么做?我尝试了
-U postgres
,但即使没有密码提示也出现了错误。基本上,我在Postgres中寻找'mysql-u root-p'。

转储到标准输出,并让另一个操作系统用户写入该文件

假设您是
根用户

# (su postgres -c 'pg_dump -U postgres dbname') > /path/to/backup.sql

生成的文件将由
root

创建并写入标准输出,并让另一个OS用户写入该文件

假设您是
根用户

# (su postgres -c 'pg_dump -U postgres dbname') > /path/to/backup.sql

生成的文件将由
root

@Gill创建和写入:您写道
postgres
用户没有写入权限,但是否
root
也不能在任何地方写入?你必须找到一个有写权限的目录,否则只能进行远程转储。更漂亮的版本:
sudo-u postgres pg_dump-Fp database_name>dump.sql
@Gill:你写的是
postgres
用户没有写权限,但是不是
root
也不能在任何地方写?您必须找到具有写权限的目录,否则只能进行远程转储。更漂亮的版本:
sudo-u postgres pg\u dump-Fp database\u name>dump.sql