Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

PostgreSQL Set Up .bash_profile

  • Here we will discuss about how to setup ".bash_profile" For postgres database
  • If we set up "bash_profile" already means we can access postgres Utility at Linux home path without going utility path
  • Here i explained About postgres utility example with or without   ".bash_profile"
Step 1:Go to pg_env file and open it using "cat" command Like Following 
[root@r1 ~]# cd /opt/PostgreSQL/9.3/
3rd_party_licenses.txt    installer/                scripts/
bin/                      lib/                      share/
data/                     license.txt               stackbuilder/
doc/                      pgAdmin3/                 uninstall-postgresql
include/                  pg_env.sh                 uninstall-postgresql.dat

[root@r1 ~]# cat /opt/PostgreSQL/9.3/pg_env.sh 
#!/bin/sh
# The script sets environment variables helpful for PostgreSQL

export PATH=/opt/PostgreSQL/9.3/bin:$PATH
export PGDATA=/opt/PostgreSQL/9.3/data
export PGDATABASE=postgres
export PGUSER=postgres
export PGPORT=5432
export PGLOCALEDIR=/opt/PostgreSQL/9.3/share/locale
export MANPATH=$MANPATH:/opt/PostgreSQL/9.3/share/man
Step 2:Copy the "pg_env" file and paste into the ".bash_profile"Like following 
[postgres@r1 ~]$ cat .bash_profile 
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
 
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/PostgreSQL/9.3/bin:$PATH
export PGDATA=/opt/PostgreSQL/9.3/data
export PGDATABASE=postgres
export PGUSER=postgres
export PGPORT=5432
export PGLOCALEDIR=/opt/PostgreSQL/9.3/share/locale
export MANPATH=$MANPATH:/opt/PostgreSQL/9.3/share/man
Step 3:Run the Bash Profile as "Postgres user"
[postgres@r1 ~]$ . .bash_profile 
Step 4:Then you can easily connect the Postgres server using with "psql" Utility without going utility path
[postgres@r1 ~]$ psql
Password: 
psql.bin (9.3.14)
Type "help" for help.
 
No entry for terminal type "xterm";
using dumb terminal settings.
postgres=# 
Step 5:Access the Postgres Utility from  Linux home path
Run the Bash_profile at home path:
[postgres@r1 ~]$ . .bash_profile 
[postgres@r1 ~]$ pwd
/home/postgres
Create "johndb" database from command line:
[postgres@r1 ~]$createdb johndb
Password: 
[postgres@r1 ~]$
connect to johndb:
[postgres@r1 ~]$psql johndb
Password: 
psql (9.1.2.2)
Type "help" for help.




Comments

Popular posts from this blog

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?

7 Steps to configure BDR replication in postgresql

How to Get Table Size, Database Size, Indexes Size, schema Size, Tablespace Size, column Size in PostgreSQL Database

Ora2PG - Oracle/MySQL to Postgres DB migration Version 20.0

PostgreSQL Introduction