psql: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory

今天在安裝好postgresql要用psql登資料庫,發現有library錯誤

[pgadm@pgrep1 ~]$ psql 
psql: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory

[pgadm@pgrep1 ~]$ cat ~/.bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs
export PGHOME=/pgbin/pghome_1
export PGDATA=/pgdata/dbdata
export PGPORT=5699
export PATH=$PATH:$PGHOME/bin

解決方法就是參數LD_LIBRARY_PATH加入PostgreSQL HOME底下的lib路徑,然後再重新讀取

[pgadm@pgrep1 pghome_1]$ vim ~/.bash_profile

export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH

[pgadm@pgrep1 pghome_1]$ source ~/.bash_profile

重新再試一次就正常了

[pgadm@pgrep1 pghome_1]$ psql 
psql: error: connection to server on socket "/tmp/.s.PGSQL.5699" failed: FATAL:  database "pgadm" does not exist

張貼留言

0 留言