Article

Table of Contents
Theme:
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles!

How to Install PostgreSQL on FreeBSD 12.2

Author: Thomas Rakwach

Last Updated: Thu, Jul 29, 2021
PostgreSQL System Admin

Introduction

PostgreSQL is a free, powerful, and high-performance ORDBMS (Object-Relational Database Management System). It has extensive documentation and supports powerful features making it well suited for large databases systems. In this article, you'll learn how to install PostgreSQL server on FreeBSD 12.2.

Prerequisites

Install PostgreSQL Server 12

  1. Update the package list.

    $ sudo pkg update
    
  2. Download and install PostgreSQL 12 server and client packages.

    $ sudo pkg install postgresql12-server postgresql12-client
    
  3. Enable PostgreSQL service to start on system boot.

    $ sudo sysrc postgresql_enable=yes
    
  4. Initialize the database.

    $ sudo service postgresql initdb
    
  5. Start the PostgreSQL service.

    $ sudo service postgresql start
    
  6. Change to the PostgreSQL account.

    $ sudo su - postgres
    
  7. Change the postgres user password.

    psql -c "alter user postgres with password 'yourPassword'"
    
  8. Create a new user named admin.

    createuser admin
    
  9. Create a testdb database owned by user admin.

    createdb testdb -O admin
    
  10. Access the PostgreSQL interactive shell.

    psql
    
  11. List all databases.

    \l
    
  12. Exit the interactive shell.

    \q
    
  13. Exit the PostgreSQL instance

    exit
    

More Information

To learn more about PostgreSQL, please see the official documentation.

Want to contribute?

You could earn up to $600 by adding new articles