PostgreSQL数据库的文件存储在哪里?
当前回答
我在docker容器中运行postgres(9.5)(在CentOS上),正如Skippy le Grand Gourou在上面的评论中提到的,这些文件位于/var/lib/postgresql/data/。
$ docker exec -it my-postgres-db-container bash
root@c7d61efe2a5d:/# cd /var/lib/postgresql/data/
root@c7d61efe2a5d:/var/lib/postgresql/data# ls -lh
total 56K
drwx------. 7 postgres postgres 71 Apr 5 2018 base
drwx------. 2 postgres postgres 4.0K Nov 2 02:42 global
drwx------. 2 postgres postgres 18 Dec 27 2017 pg_clog
drwx------. 2 postgres postgres 6 Dec 27 2017 pg_commit_ts
drwx------. 2 postgres postgres 6 Dec 27 2017 pg_dynshmem
-rw-------. 1 postgres postgres 4.4K Dec 27 2017 pg_hba.conf
-rw-------. 1 postgres postgres 1.6K Dec 27 2017 pg_ident.conf
drwx------. 4 postgres postgres 39 Dec 27 2017 pg_logical
drwx------. 4 postgres postgres 36 Dec 27 2017 pg_multixact
drwx------. 2 postgres postgres 18 Nov 2 02:42 pg_notify
drwx------. 2 postgres postgres 6 Dec 27 2017 pg_replslot
drwx------. 2 postgres postgres 6 Dec 27 2017 pg_serial
drwx------. 2 postgres postgres 6 Dec 27 2017 pg_snapshots
drwx------. 2 postgres postgres 6 Sep 16 21:15 pg_stat
drwx------. 2 postgres postgres 63 Nov 8 02:41 pg_stat_tmp
drwx------. 2 postgres postgres 18 Oct 24 2018 pg_subtrans
drwx------. 2 postgres postgres 6 Dec 27 2017 pg_tblspc
drwx------. 2 postgres postgres 6 Dec 27 2017 pg_twophase
-rw-------. 1 postgres postgres 4 Dec 27 2017 PG_VERSION
drwx------. 3 postgres postgres 92 Dec 20 2018 pg_xlog
-rw-------. 1 postgres postgres 88 Dec 27 2017 postgresql.auto.conf
-rw-------. 1 postgres postgres 21K Dec 27 2017 postgresql.conf
-rw-------. 1 postgres postgres 37 Nov 2 02:42 postmaster.opts
-rw-------. 1 postgres postgres 85 Nov 2 02:42 postmaster.pid
其他回答
要查看数据目录的位置,请使用此查询。
show data_directory;
要查看所有运行时参数,请使用
show all;
您可以创建表空间来在文件系统的其他部分存储数据库对象。要查看可能不在该数据目录中的表空间,请使用此查询。
SELECT *, pg_tablespace_location(oid) FROM pg_tablespace;
Mac系统:/Library/PostgreSQL/9.0/data/base
不能进入目录,但可以通过:sudo du -hc data查看内容
打开pgAdmin,进入特定数据库的属性。找到OID,然后打开目录
<POSTGRESQL_DIRECTORY>/data/base/<OID>
这里应该有您的DB文件。
在Windows上,PostgresSQL文档中描述的PGDATA目录在C:\Program Files\PostgreSQL\8.1\data.这样的地方特定数据库的数据位于(例如)C:\Program Files\PostgreSQL\8.1\data\base\ 100929下,我猜100929是数据库号。
每个人都已经回答了,但只是最新的更新。如果您想知道所有配置文件的位置,那么在shell中运行这个命令
SELECT name, setting FROM pg_settings WHERE category = 'File Locations';
推荐文章
- 如何在Postgres中获得两个字段的MIN() ?
- 截断Postgres数据库中的所有表
- 如何连接列在Postgres选择?
- 将varchar字段的类型更改为整数:"不能自动转换为整数类型"
- PostgreSQL可以索引数组列吗?
- PostgreSQL:角色不允许登录
- 如何查找Postgres / PostgreSQL表及其索引的磁盘大小
- 是使用各有一个模式的多个数据库更好,还是使用一个数据库有多个模式更好?
- 如果字符串包含
- 对于PostgreSQL表来说,多大才算太大?
- 将一列的多个结果行连接为一列,按另一列分组
- 使用pgadmin连接到heroku数据库
- 在PostgreSQL中快速发现表的行数
- 更改varchar列的大小为较低的长度
- 如何首次配置postgresql ?