Ubuntu& PostgreSQL第24行:/usr/local/bin/psql.bin:没有这样的文件或目录

时间:2016-10-31 07:10:01

标签: postgresql ubuntu

我已在此路径中/opt/PostgreSQL/9.6

在Ubuntu 16.10中安装了Postgresql

现在,如果我直接调用/opt/PostgreSQL/9.6/bin/psql,它可以正常工作并提示输入密码,如下所示

root@neo-linux /u/l/bin# /opt/PostgreSQL/9.6/bin/psql -d postgres -U postgres
Password for user postgres: 

现在我已将psql配置为/usr/local/bin中的软链接,如下所示

lrwxrwxrwx 1 root root          28 Oct 31 17:57 psql -> /opt/PostgreSQL/9.6/bin/psql*

当我只是致电psql时,它会抛出以下错误消息。

root@neo-linux /u/l/bin# psql
/usr/local/bin/psql: line 24: /usr/local/bin/psql.bin: No such file or directory

以下是/opt/PostgreSQL/9.6

的内容
root@neo-linux /u/l/bin# cat psql
#!/bin/bash

# If there's an OS supplied version of libreadline, try to make use of it,
# as it's more reliable than libedit, which we link with.
PLL=""
if [ -f /lib64/libreadline.so.6 ];
then
    PLL=/lib64/libreadline.so.6
elif [ -f /lib64/libreadline.so.5 ];
then
    PLL=$PLL:/lib64/libreadline.so.5
elif [ -f /lib/libreadline.so.6 ];
then
    PLL=$PLL:/lib/libreadline.so.6
elif [ -f /lib/libreadline.so.5 ];
then
    PLL=$PLL:/lib/libreadline.so.5
fi
# Get the PG bin directory path relative to psql caller script.
PG_BIN_PATH=`dirname "$0"`

if [ -z "$PLL" ];
then
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PG_BIN_PATH/../lib "$PG_BIN_PATH/psql.bin" "$@"
else
    LD_PRELOAD=$PLL LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PG_BIN_PATH/../lib "$PG_BIN_PATH/psql.bin" "$@"
fi

我错过了什么?

1 个答案:

答案 0 :(得分:2)

问题是它在同一目录中查找另一个文件,但那并不存在。您也可以创建指向psql.bin的符号链接,但为什么不正确设置PATH

export PATH=$PATH:/opt/PostgreSQL/9.6/bin

如果您的问题是版本号,您可以这样做:

ln -s /opt/PostgreSQL/9.6 /opt/PostgreSQL/current
export PATH=$PATH:/opt/PostgreSQL/current/bin