

Psql -host your-servers-dns-or-ip -username postgres -password -dbname template1
#LINUX POSTGRESQL CREATE DATABASE INSTALL#
You can test server connections from other machines by using the PostgreSQL client as follows, replacing the domain name with your actual server domain name or IP address: sudo apt install postgresql-client Please refer to the PostgreSQL Administrator’s Guide to configure more parameters. The above configuration is not complete by any means. From a terminal prompt enter the following to restart PostgreSQL: sudo systemctl restart rvice On your postgresql server this uses the certificate created by ‘ssl-cert’ package which is great, but for production use you should consider updating that with a proper certificate from a recognized CA.įinally, you should restart the PostgreSQL service to initialise the new configuration. Postgresql in Ubuntu has the ssl feature built in and configured by default, so it works right away. The config statement ‘hostssl’ used here will reject tcp connections that would not use ssl.
#LINUX POSTGRESQL CREATE DATABASE PASSWORD#
ALTER USER postgres with encrypted password 'your_password' Īfter configuring the password, edit the file /etc/postgresql/*/main/pg_hba.conf to use scram-sha-256 authentication with the postgres user, allowed for the template1 database, from any system in the local network (which in the example is 192.168.122.1/24) : hostssl template1 postgres 192.168.122.1/24 scram-sha-256 You can run the following SQL command at the psql prompt to configure the password for the user postgres. Once you connect to the PostgreSQL server, you will be at an SQL prompt.

The above command connects to PostgreSQL database template1 as user postgres. Run the following command at a terminal prompt to connect to the default PostgreSQL template database: sudo -u postgres psql template1 Now that we can connect to our PostgreSQL server, the next step is to set a password for the postgres user. ‘*’ will allow all available IP interfaces (IPv4 and IPv6), to only listen for IPv4 set ‘0.0.0.0’ while ‘::’ allows listening for all IPv6 addresses.įor details on other parameters, refer to the configuration file or to the PostgreSQL documentation for information on how they can be edited. Locate the line: #listen_addresses = ‘localhost’ and change it to *: listen_addresses = '*' There are detailed comments in the file to guide you.īy default only connections from the local system are allowed, to enable all other computers to connect to your PostgreSQL server, edit the file /etc/postgresql/*/main/nf. To configure IDENT authentication, add entries to the /etc/postgresql/*/main/pg_nf file.

For example, if you install PostgreSQL 14, the configuration files are stored in the /etc/postgresql/14/main directory. PostgreSQL configuration files are stored in the /etc/postgresql//main directory. The following discussion assumes that you wish to enable TCP/IP connections and use the MD5 method for client authentication. Please refer to the PostgreSQL Administrator’s Guide if you would like to configure alternatives like Kerberos. In Ubuntu, peer is the default authentication method used for local connections, while scram-sha-256 is the default for host connections (this used to be md5 until Ubuntu 21.10). PostgreSQL supports multiple client authentication methods. The database service is automatically configured with viable defaults, but can be customised based on your specific needs. To install PostgreSQL, run the following command in the command prompt: sudo apt install postgresql PostgreSQL (also known as Postgres) is an object-relational database system that has the features of traditional commercial database systems with enhancements to be found in next-generation database management systems (DBMS).

Multi-node configuration with Docker-Composeĭistributed Replicated Block Device (DRBD)
