- 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"
[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/manStep 3:Run the Bash Profile as "Postgres user"
[postgres@r1 ~]$ . .bash_profileStep 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 pathRun the Bash_profile at home path:
[postgres@r1 ~]$ . .bash_profile [postgres@r1 ~]$ pwd /home/postgresCreate "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.
No comments:
Post a Comment