Skip to main content
Skip table of contents

PostgreSQL installation on macOS

PostgreSQL is an open-source object-relational database. It is a popular database choice when using a relational database. Latest version of PostgreSQL is 10.x and but on some servers we are also using version 9.6.

Steps

Step 1: Download the postgresql package

Click on the following link to download the package and select the postgresql version and your operating system(mac)

https://www.enterprisedb.com/downloads/postgres-postgresql-downloads#macosx

Step 2: Install the postgresql package

Double-click on the package and install it. You need to provide the postgressql user password.

Step 3: Set environment variables for macOS

Open a terminal in your Mac and then open the profile file with any editor and paste the below line in your profile file.

Profile file can be .profile or .bash_profile in your home directory:

XML
export PATH=/Library/PostgreSQL/9.6/bin/:$PATH


Step 4: Create corpus user and database

Copy the postgresql-create-user.sql and postgresql-create-db.sql files into your Mac from the censhare-Server/database directory.

Then execute the "postgresql-create-user.sql" script to create the "corpus" user, "corpus" database and "type casts" by the following command:

XML
psql -U postgres -f (path to postgresql-create-user.sql)

Create tables within the "corpus" database by executing "postgresql-create-db.sql" script by the following command:

XML
psql -U corpus -d corpus -f (path to postgresql-create-db.sql)

You might face the below issue while running the above script:

XML
psql: FATAL: Peer authentication failed for user "corpus"

To resolve this issue, edit the “pg_hba.conf” file and change the parameter as "peer" to "trust". You can find the location of "pg_hba.conf" file in the "/data" directory of PostgreSQL i.e. "/var/lib/pgsql/10/data" in version 10.x and for version 9.6 it's path "/var/lib/pgsql/9.6/data".

XML
# "local" is for Unix domain socket connections only local all all trust

After the above changes, reload the configuration file(pg_hba.conf) by using the following command from Postgres OS user. Run this command from postgres software /bin directory:

XML
For PostgreSQL-10 version:

[root@de-nue-sri ~]# su - postgres
-bash-4.2$ cd /usr/pgsql-10/bin/
-bash-4.2$ ./pg_ctl reload -D /var/lib/pgsql/10/data/
server signaled
-bash-4.2$

For PostgreSQL-9.6 version:

[root@de-nue-sri ~]# su - postgres
-bash-4.2$ cd /usr/pgsql-9.6/bin/
-bash-4.2$ ./pg_ctl reload -D /var/lib/pgsql/9.6/data/
server signaled
-bash-4.2$

Step 5: Configuration change in censhare

After creating the PostgreSQL database, change the config.xml file and provide the information of the PostgreSQL database.

Open censhare-Custom/censhare-Server/app/services/database/config.xml and replace the line as following:

XML
old > ("jdbc:oracle:thin:@localhost:1521:XE")
new > ("jdbc:postgresql://localhost:5432/corpus")  
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.