我该如何在Ubuntu 10.04文件系统中找到Postgres 8.x数据库文件保存的位置?
我该如何在Ubuntu 10.04文件系统中找到Postgres 8.x数据库文件保存的位置?
在PostgreSQL提示符下,只需执行此查询:
SHOW data_directory;
还可以参考Ubuntu手册: https://help.ubuntu.com/10.04/serverguide/C/postgresql.html
以下是我在Ubuntu中查找Postgres数据库文件目录的方法:
在终端中运行以下命令以切换用户到postgres
用户:
su - postgres
这将会请求 postgres
用户的密码,这个密码是在安装PostgreSQL时设置的。
接下来,您需要登录到psql
终端/提示符。可以通过运行以下代码来完成:
psql
它还将请求您在设置PostgreSQL时设置的postgres
密码。
如果您成功登录,将会看到类似于这样的提示:
psql (11.5 (Ubuntu 11.5-3.pgdg18.04+1), server 10.10 (Ubuntu 10.10-1.pgdg18.04+1))
Type "help" for help.
postgres=#
此时,您将执行以下查询以显示存储在Linux机器上的Postgres数据库文件的目录:
SHOW data_directory;
data_directory
-----------------------------
/var/lib/postgresql/10/main
(1 row)
/etc/postgresql/10/main
。请注意,10
是我的服务器上安装的PostgreSQL版本号。您的版本可能是9.5
,11
或12
或任何其他版本。运行命令psql --version
以确认您的PostgreSQL版本。cd ~
cd /etc/postgresql/10/main
data_directory
/var/lib/postgresql/9.1/main (1 行) - Taimoor Changaiz