Skip to main content

Linux Postgress Installation for Netbox

sudo yumapt update
sudo apt install -y postgresql-serverpostgresql

Before continuing, verify that you have installed PostgreSQL 12 or later:


psql -V

Database Creation

At a minimum, we need to create a database for NetBox and assign it a username and password for authentication. Start by invoking the PostgreSQL shell as the system Postgres user.


sudo postgresql-setup-u postgres psql

Within the shell, enter the following commands to create the database and user (role), substituting your own value for the password:


CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'choserandompwd';
ALTER DATABASE netbox OWNER TO netbox;
--initdb

 the next two commands are needed on PostgreSQL 15 and later \connect netbox; GRANT CREATE ON SCHEMA public TO netbox

Once

complete,

modifyenter /var/lib/pqsql/data/pg_hba.conf\q to supportexit MD5the PostgreSQL shell.

Verify Service Status

You can verify that authentication works by changingexecuting identthe psql command and passing the configured username and password. (Replace localhost with your database server if using a remote database.)

$ psql --username netbox --password --host localhost netbox
Password for user netbox: 
psql (12.5 (Ubuntu 12.5-0ubuntu0.20.04.1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

netbox=> \conninfo
You are connected to md5

database "netbox" as user "netbox" on host "localhost" (address "127.0.0.1") at port "5432". SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off) netbox=> \q

image.pngIf successful, you will enter a netbox prompt. Type \conninfo to confirm your connection, or type \q to exit.

image.png

 

Start the service

sudo systemctl enable --now postgresql