Где лежит конфиг postgresql linux

Location of postgresql.conf and pg_hba.conf on an Ubuntu server

Where are the files postgresql.conf and pg_hba.conf on a Linux server running PostgreSQL 8.4 installed from Ubuntu repos?

The problem is b/w the chair and the keyboard. It depends on how you installed it. Did you use source tar-gz file or did you use apt utility. If you download tar-gzipped file and installed it. The pg_hba.conf file does not exist yet unless you initialize your data directory. The INSTALL/Readme file has that info. You will find pg_hba.conf file in whatever you selected as your data directory. Secondly, if you used apt utility then you should find it in /etc/postgresql/8.4/main you can also do a ‘find’ on the filename but doing that on the entire disk is cpu-consuming.

Installing from source to the default install location, you run the following: /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data before starting postgres and hba file will be created in that directory.

6 Answers 6

Looking for «pg_hba.conf ubuntu» on Google gives you

which shows the location of the files.

The documentation states the following:

Client authentication is controlled by a configuration file, which traditionally is named pg_hba.conf and is stored in the database cluster’s data directory. (HBA stands for host-based authentication.) A default pg_hba.conf file is installed when the data directory is initialized by initdb. It is possible to place the authentication configuration file elsewhere, however; see the hba_file configuration parameter.

Note it says stored in the database cluster’s data directory and that it’s possible to place it elsewhere, via a configuration parameter. Official documentation cannot point you to a specific folder because the actual location depends on both how the OS maker and the machine’s administrator have set PostgreSQL up. Remember PostgreSQL supports a lot of different operating systems (and Linux distributions.)

Читайте также:  Linux включить dhcp на интерфейсе

As Neutrino shows, if you can access your server via psql, you can tell it to show you the file location.

  1. locate will help you find files you know the name of but not the location
  2. Debian based distributions place under /usr/share/doc documentation on how they set up different packages by default, I’m sure you’ll find under /usr/share/doc/postgresql-8.4 (or maybe just postgresql) info about the configuration files. Very useful to read in case they have modified some standard behavior.

Источник

Где лежит конфиг postgresql linux

In addition to the postgresql.conf file already mentioned, PostgreSQL uses two other manually-edited configuration files, which control client authentication (their use is discussed in Chapter 21). By default, all three configuration files are stored in the database cluster’s data directory. The parameters described in this section allow the configuration files to be placed elsewhere. (Doing so can ease administration. In particular it is often easier to ensure that the configuration files are properly backed-up when they are kept separate.)

Specifies the directory to use for data storage. This parameter can only be set at server start.

Specifies the main server configuration file (customarily called postgresql.conf ). This parameter can only be set on the postgres command line.

Specifies the configuration file for host-based authentication (customarily called pg_hba.conf ). This parameter can only be set at server start.

Specifies the configuration file for user name mapping (customarily called pg_ident.conf ). This parameter can only be set at server start. See also Section 21.2.

Specifies the name of an additional process-ID (PID) file that the server should create for use by server administration programs. This parameter can only be set at server start.

In a default installation, none of the above parameters are set explicitly. Instead, the data directory is specified by the -D command-line option or the PGDATA environment variable, and the configuration files are all found within the data directory.

If you wish to keep the configuration files elsewhere than the data directory, the postgres -D command-line option or PGDATA environment variable must point to the directory containing the configuration files, and the data_directory parameter must be set in postgresql.conf (or on the command line) to show where the data directory is actually located. Notice that data_directory overrides -D and PGDATA for the location of the data directory, but not for the location of the configuration files.

Читайте также:  Alt linux репозитории debian

If you wish, you can specify the configuration file names and locations individually using the parameters config_file , hba_file and/or ident_file . config_file can only be specified on the postgres command line, but the others can be set within the main configuration file. If all three parameters plus data_directory are explicitly set, then it is not necessary to specify -D or PGDATA .

When setting any of these parameters, a relative path will be interpreted with respect to the directory in which postgres is started.

Submit correction

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.

Источник

Locate Configuration Files in PostgreSQL on Ubuntu

Locate Configuration Files in PostgreSQL on Ubuntu

  1. Use the SHOW Command to Locate Configuration Files in PostgreSQL on Ubuntu
  2. Use the locate Command to Locate Configuration Files in PostgreSQL on Ubuntu
  3. Use the Running Service of PostgreSQL to Locate Configuration Files in PostgreSQL on Ubuntu

A conf file adds custom configuration parameters for the database. These configuration files change how the database normally works to achieve the desired functionality.

In this tutorial, we will learn how to find the location of these files on our computer to ensure we make changes when we need to perform some customization.

Use the SHOW Command to Locate Configuration Files in PostgreSQL on Ubuntu

When logging in to the database, we can execute the following command, which returns the absolute path where the configuration file is stored.

Copy and paste the below command to the terminal and press the Enter button on your keyboard. Enter your password in the prompt that returns and press Enter again.

david@david-HP-ProBook-6470b:~$ psql -U postgres -c 'SHOW config_file' Password for user postgres: 

The following is the result of executing the above command.

 config_file -----------------------------------------  /etc/postgresql/14/main/postgresql.conf (1 row) 

Navigate to the returned path and find a postgresql.conf file. Edit the file as you want and ensure that you save it to make the changes persistent.

Читайте также:  Настройка linux через proxy

Use the locate Command to Locate Configuration Files in PostgreSQL on Ubuntu

The locate command is used to search for files in a file system. Use the following command to generate a database of files that can be searched by the locate command.

david@david-HP-ProBook-6470b:~$ sudo updatedb 

To search for a configuration file named postgresql.conf in the database files generated above, copy and paste the following command to your terminal and press the Enter button on your keyboard.

david@david-HP-ProBook-6470b:~$ locate postgresql.conf 

The result of the above command returns the path to the configuration file. The following is the path returned by the locate command.

/etc/postgresql/14/main/postgresql.conf /usr/share/postgresql/14/postgresql.conf.sample 

Navigate to the path returned and find a file named postgresql.conf . Edit the file and make the desired changes.

Use the Running Service of PostgreSQL to Locate Configuration Files in PostgreSQL on Ubuntu

Execute the following command to the details of the PostgreSQL service running. The details of the PostgreSQL contain information such as process id and the location of the configuration file in which we are interested.

david@david-HP-ProBook-6470b:~$ ps aux | grep 'postgres *-D' 

The following is the result of executing the above command.

postgres 1165 0.0 0.2 322432 27900 ? Ss 17:43 0:00 /usr/lib/postgresql/14/bin/postgres -D /var/lib/postgresql/14/main -c config_file=/etc/postgresql/14/main/postgresql.conf 

The last value of the data returned provides the absolute path for the configuration file. Edit the file as required, and ensure you save the file to ensure the changes are persistent.

David is a back end developer with a major in computer science. He loves to solve problems using technology, learning new things, and making new friends. David is currently a technical writer who enjoys making hard concepts easier for other developers to understand and his work has been published on multiple sites.

Related Article — PostgreSQL Configuration

Источник

Оцените статью
Adblock
detector