PostgreSQL database default location on Linux

后端 未结 8 1294
南笙
南笙 2020-12-12 12:56

What is the default directory where PostgreSQL will keep all databases on Linux?

相关标签:
8条回答
  • 2020-12-12 13:34

    The command pg_lsclusters (at least under Linux / Ubuntu) can be used to list the existing clusters and with it also the data directory:

    Ver Cluster Port Status Owner    Data directory               Log file
    9.5 main    5433 down   postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
    10  main    5432 down   postgres /var/lib/postgresql/10/main  /var/log/postgresql/postgresql-10-main.log
    
    0 讨论(0)
  • 2020-12-12 13:36

    Below query will help to find postgres configuration file.

    postgres=# SHOW config_file;
                 config_file
    -------------------------------------
     /var/lib/pgsql/data/postgresql.conf
    (1 row)
    
    [root@node1 usr]# cd /var/lib/pgsql/data/
    [root@node1 data]# ls -lrth
    total 48K
    -rw------- 1 postgres postgres    4 Nov 25 13:58 PG_VERSION
    drwx------ 2 postgres postgres    6 Nov 25 13:58 pg_twophase
    drwx------ 2 postgres postgres    6 Nov 25 13:58 pg_tblspc
    drwx------ 2 postgres postgres    6 Nov 25 13:58 pg_snapshots
    drwx------ 2 postgres postgres    6 Nov 25 13:58 pg_serial
    drwx------ 4 postgres postgres   36 Nov 25 13:58 pg_multixact
    -rw------- 1 postgres postgres  20K Nov 25 13:58 postgresql.conf
    -rw------- 1 postgres postgres 1.6K Nov 25 13:58 pg_ident.conf
    -rw------- 1 postgres postgres 4.2K Nov 25 13:58 pg_hba.conf
    drwx------ 3 postgres postgres   60 Nov 25 13:58 pg_xlog
    drwx------ 2 postgres postgres   18 Nov 25 13:58 pg_subtrans
    drwx------ 2 postgres postgres   18 Nov 25 13:58 pg_clog
    drwx------ 5 postgres postgres   41 Nov 25 13:58 base
    -rw------- 1 postgres postgres   92 Nov 25 14:00 postmaster.pid
    drwx------ 2 postgres postgres   18 Nov 25 14:00 pg_notify
    -rw------- 1 postgres postgres   57 Nov 25 14:00 postmaster.opts
    drwx------ 2 postgres postgres   32 Nov 25 14:00 pg_log
    drwx------ 2 postgres postgres 4.0K Nov 25 14:00 global
    drwx------ 2 postgres postgres   25 Nov 25 14:20 pg_stat_tmp
    
    0 讨论(0)
提交回复
热议问题