• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to Install PostgreSQL in FreeBSD

880

To Install PostgreSQL in FreeBSD

PostgreSQL is an open source relational database management system (DBMS). It can manage workloads of large internet facing applications with several concurrent users. It is mainly used for secure data storage. The postgreSQL supports transactions, subselects, triggers, views and sophisticated locking. Installation of PostgreSQL in FreeBSD is explained in this article.


Installation of PostgreSQL

Before installing the PostgreSQL, run the following command to update the mirrors.

root@linuxhelp:~ # freebsd-update fetch
Looking up update.FreeBSD.org mirrors... 4 mirrors found.
Fetching public key from update5.freebsd.org... done.
Fetching metadata signature for 10.3-RELEASE from update5.freebsd.org... done.
Fetching metadata index... done.
Fetching 2 metadata files... done.
Inspecting system... done.
Preparing to download files... done.
Fetching 379 patches.....10....20....30....40....50....60....70....80....90....100....110....120....130....140....150....160....170....180....190....200....210....220....230....240....250....260....270....280....290....300....310....320....330....340....350....360....370.... done.
Applying patches... done.
Fetching 9 files... done.

The following files will be added as part of updating to 10.3-RELEASE-p12:
/usr/src/contrib/libarchive/libarchive/test/test_write_disk_secure744.c
/usr/src/contrib/libarchive/libarchive/test/test_write_disk_secure745.c
/usr/src/contrib/libarchive/libarchive/test/test_write_disk_secure746.c
/usr/src/contrib/ntp/README.pullrequests
/usr/src/contrib/ntp/lib/isc/tsmemcmp.c

Then install the updated packages with the " update install" command.

root@linuxhelp:~ # freebsd-update install
Installing updates... done.

Now its time to install the PostgreSQL server and client.

root@linuxhelp:~ # pkg install postgresql93-server postgresql93-client
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100%    944 B   0.9kB/s    00:01    
Fetching packagesite.txz: 100%    5 MiB 213.6kB/s    00:27    
Processing entries: 100%
New packages to be INSTALLED:
    postgresql93-server: 9.3.14_1
    postgresql93-client: 9.3.14_1

Number of packages to be installed: 2

The process will require 25 MiB more space.
5 MiB to be downloaded.

Proceed with this action? [y/N]: y
Fetching postgresql93-server-9.3.14_1.txz: 100%    3 MiB 150.7kB/s    00:22    
Fetching postgresql93-client-9.3.14_1.txz: 100%    2 MiB 107.7kB/s    00:19    
Checking integrity... done (0 conflicting)
[1/2] Installing postgresql93-client-9.3.14_1...
[1/2] Extracting postgresql93-client-9.3.14_1: 100%
[2/2] Installing postgresql93-server-9.3.14_1...
===>  Creating groups.
Creating group ' pgsql'  with gid ' 70' .
===>  Creating users
Creating user ' pgsql'  with uid ' 70' .

.
.
.
.
To set limits, environment stuff like locale and collation and other
things, you can set up a class in /etc/login.conf before initializing
the database. Add something similar to this to /etc/login.conf:
---
postgres:
    :lang=en_US.UTF-8:
    :setenv=LC_COLLATE=C:
    :tc=default:
---
and run `cap_mkdb /etc/login.conf' .
Then add ' postgresql_class=" postgres" '  to /etc/rc.conf.

======================================================================

To initialize the database, run

  /usr/local/etc/rc.d/postgresql initdb

You can then start PostgreSQL by running:

  /usr/local/etc/rc.d/postgresql start

For postmaster settings, see ~pgsql/data/postgresql.conf

NB. FreeBSD' s PostgreSQL port logs to syslog by default
    See ~pgsql/data/postgresql.conf for more info

======================================================================

To run PostgreSQL at startup, add
' postgresql_enable=" YES" '  to /etc/rc.conf

Next add the postgreSQL service to rc.conf file.

root@linuxhelp:~ # sysrc postgresql_enable=" YES" 
postgresql_enable:  ->  YES

Then initialize the postgreSQL server with the following command.

root@linuxhelp:~ # service postgresql initdb
The files belonging to this database system will be owned by user " pgsql" .
This user must also own the server process.

The database cluster will be initialized with locale " C" .
The default text search configuration will be set to " english" .

Data page checksums are disabled.

creating directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /usr/local/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects'  descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok

WARNING: enabling " trust"  authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/bin/postgres -D /usr/local/pgsql/data
or
    /usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

Once the above process gets completed, configure the postgreSQL server as shown below,

root@linuxhelp:~ # nano -c /usr/local/pgsql/data/postgresql.conf
.
.
.
listen_addresses = ' *' 
.
.
.
port = 5432
.
.

Done!


To Start PostgreSQL Service

Run the following command to start the postgresSQL service.

root@linuxhelp:~ # service postgresql start
LOG:  ending log output to stderr
HINT:  Future log output will go to log destination " syslog" .

Here you need to set user password for postgreSQL user.

root@linuxhelp:~ # passwd pgsql
Changing local password for pgsql
New Password:
Retype New Password:

Then utilize the " su" command to run the postgresql in command prompt.

Create the user and set password to create database.

root@linuxhelp:~ # su pgsql

$ createuser -sdrP linuxhelpuser
Enter password for new role:
Enter it again:
$ createdb -O linuxhelpuser linuxhelpdb
$ psql linuxhelpdb
psql (9.3.14)
Type " help"  for help.

linuxhelpdb=# list
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------+---------------+----------+---------+-------+-------------------
linuxhelpdb | linuxhelpuser | UTF8 | C | C |
postgres | pgsql | UTF8 | C | C |
template0 | pgsql | UTF8 | C | C | =c/pgsql +
| | | | | pgsql=CTc/pgsql
template1 | pgsql | UTF8 | C | C | =c/pgsql +
| | | | | pgsql=CTc/pgsql
(4 rows)

Tags:
christian
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

How do I change the sort ordering of textual data in PostgreSQL?

A

PostgreSQL sorts textual data according to the ordering that is defined by the current locale, which is selected during initdb.

Q

Does the PostgreSQL be similar to MySQL?

A

No, IT is totally different from MYSQL.
Both systems are relational database systems and using SQL, the Structured Query Language, as a means for interacting with it. However, there are some differences between the MySQL and PostgreSQL syntax. ... PostgreSQL is case sensitive.

Q

How do I control connections from other hosts?

A

PostgreSQL only allows connections from the local machine using Unix domain sockets or TCP/IP connections. Other machines will not be able to connect unless you modify listen_addresses in the postgresql.conf file, enable host-based authentication by modifying the $PGDATA/pg_hba.conf file, and restart.

Q

What happened to the database dump feature in phpPgAdmin?

A

You need to configure phpPgAdmin (in the config.inc.php file) to point to the location of the pg_dump and pg_dumpall utilities on your server. Once you have done that, the database export feature will appear.

Q

Why phpPgAdmin ask me to re-enter login information for every page I access?

A

You most certainly have a problem with your PHP sessions. Make sure:
your browser accept cookies if your session ID relies on them
PHP has write access to the path set in the parameter “session.save_path” of your php.ini

Related Tutorials in How to Install PostgreSQL in FreeBSD

Related Tutorials in How to Install PostgreSQL in FreeBSD

How to install squid proxy server on freeBSD
How to install squid proxy server on freeBSD
Feb 10, 2017
How To Install PostgreSQL 10 on CentOS7
How To Install PostgreSQL 10 on CentOS7
Feb 26, 2018
How to use Automysqlbackup and Autopostgresqlbackup
How to use Automysqlbackup and Autopostgresqlbackup
Apr 30, 2016
How to install OPNSense
How to install OPNSense
Jul 21, 2016
How to Install PostgreSQL 11 on Ubuntu 19.04
How to Install PostgreSQL 11 on Ubuntu 19.04
Jun 8, 2019
How To Install PostgreSQL 10 on Linux Mint 18.3
How To Install PostgreSQL 10 on Linux Mint 18.3
Jun 2, 2018
How to Install PostgreSQL in FreeBSD
How to Install PostgreSQL in FreeBSD
Nov 9, 2016
How to install DataGrip in Ubuntu
How to install DataGrip in Ubuntu
Jul 23, 2016

Related Forums in How to Install PostgreSQL in FreeBSD

Related Forums in How to Install PostgreSQL in FreeBSD

PostgreSQL
stalin class=
How to uninstall postgresql from ubuntu
Nov 2, 2017
PostgreSQL
tommyhilten class=
Phpmyadmin : Login disallowed for security reasons in postgresql
Nov 3, 2017
Database
john class=
Warning: mysqli::__construct(): (HY000/2002): No route to host
May 23, 2017
MySQL
gabriel class=
ERROR 1558 (HY000): Column count of mysql.user is wrong. Expected 43, found 42. Created with MySQL 50560, now running 50642
Dec 14, 2018
CentOS
jayce class=
Psql : could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.45432"?
May 30, 2019
XFCE
iqbal class=
XFCE installation in freeBSD
Nov 14, 2017
PostgreSQL
michael class=
Postgres password authentication fails
Nov 3, 2021
PostgreSQL
isaac class=
Unable to configure the PostgreSQL in openproject
May 17, 2019

Related News in How to Install PostgreSQL in FreeBSD

Related News in How to Install PostgreSQL in FreeBSD

Amazon Web Services offers Aurora Cloud DB accordant with PostgreSQL
Amazon Web Services offers Aurora Cloud DB accordant with PostgreSQL
Oct 27, 2017
Security breach in Indiana Pacers Database
Security breach in Indiana Pacers Database
May 24, 2019
GandCrab Ransomware Infection Made by Scanning MySQL Databases
GandCrab Ransomware Infection Made by Scanning MySQL Databases
May 28, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Owen ?
How to add SSH key to my Gitlab account

I need to add the SSH key in my gitlab account. How to do so ????

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.