[英]Where Postgres database files are saved in ubuntu?
如何在 Ubuntu 10.04 文件系统中找到 Postgres 8.x 数据库文件的保存位置?
In the postgres prompt, just execute this query:在 postgres 提示中,只需执行以下查询:
SHOW data_directory;
Check also the Ubuntu manual: https://help.ubuntu.com/10.04/serverguide/C/postgresql.html另请查看 Ubuntu 手册: https : //help.ubuntu.com/10.04/serverguide/C/postgresql.html
Here's how I located the directory of my Postgres database files in Ubuntu:以下是我在 Ubuntu 中定位 Postgres 数据库文件目录的方法:
Run the command below in your terminal to switch user to postgres
user:在终端中运行以下命令将用户切换为postgres
用户:
su - postgres
It will request for the postgres
user password which you set up when you were setting up PostgreSQL on your machine.它将请求您在机器上设置 PostgreSQL 时设置的postgres
用户密码。
Next, you will need to login into the psql
terminal/prompt.接下来,您需要登录psql
终端/提示。 This can be accomplished by running the code below:这可以通过运行以下代码来完成:
psql
It will also request for the postgres
password which you set up when you were setting up PostgreSQL on your machine.它还会请求您在机器上设置 PostgreSQL 时设置的postgres
密码。
If you are successfully logged in, you will see a prompt similar to this:如果您成功登录,您会看到类似这样的提示:
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=#
At this point you will execute the query below to display the directory where Postgres Database files are stored on your Linux macchine:此时,您将执行以下查询以显示 Linux 机器上存储 Postgres 数据库文件的目录:
SHOW data_directory;
This should display an output similar to this:这应该显示与此类似的输出:
data_directory
-----------------------------
/var/lib/postgresql/10/main
(1 row)
You can now locate the Postgres Database files by navigating the directory that was displayed.您现在可以通过导航显示的目录来定位 Postgres 数据库文件。
However, the PostgreSQL configuration directory in Ubuntu is located in /etc/postgresql/10/main
.但是,Ubuntu 中的 PostgreSQL 配置目录位于/etc/postgresql/10/main
。 Take note that 10
is the version of my PostgreSQL installation on my server.请注意, 10
是我在服务器上安装的 PostgreSQL 版本。 Your version might be 9.5
, 11
or 12
or any other version.您的版本可能是9.5
、 11
或12
或任何其他版本。 Run the command psql --version
to confirm your PostgreSQL version.运行命令psql --version
以确认您的 PostgreSQL 版本。
Run the command below to navigate to the directory:运行以下命令以导航到目录:
cd ~
cd /etc/postgresql/10/main
That's all.就这样。
I hope this helps我希望这有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.