How to Install PostgreSQL on FreeBSD 12.2
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
- Deploy a Vultr FreeBSD 12.2 Server.
- Create non-root sudo user.
Install PostgreSQL Server 12
Update the package list.
$ sudo pkg update
Download and install PostgreSQL 12 server and client packages.
$ sudo pkg install postgresql12-server postgresql12-client
Enable PostgreSQL service to start on system boot.
$ sudo sysrc postgresql_enable=yes
Initialize the database.
$ sudo service postgresql initdb
Start the PostgreSQL service.
$ sudo service postgresql start
Change to the PostgreSQL account.
$ sudo su - postgres
Change the
postgres
user password.psql -c "alter user postgres with password 'yourPassword'"
Create a new user named
admin
.createuser admin
Create a
testdb
database owned by useradmin
.createdb testdb -O admin
Access the PostgreSQL interactive shell.
psql
List all databases.
\l
Exit the interactive shell.
\q
Exit the PostgreSQL instance
exit
More Information
To learn more about PostgreSQL, please see the official documentation.