I have installed PostgreSQL and it is working ok. However, when I went to restore a backup I got the error -bash: psql: command not found
:
[root@server1 ~]# su postgres [postgres@server1 root]$ psql -f all.sql bash: psql: command not found [postgres@server1 root]$
What have I done wrong?
If, after installing PostgreSQL, you face “psql not recognized as an internal or external command” error when you try to run psql from the command prompt, then most probably all you need to do to solve this problem is to add Postgres's bin directory to the PATH system variable (the PATH is a system variable which ...
On Windows, you can find psql in the Program Files, and you should be able to launch it in a command prompt simply by clicking on it.
Connecting to a Databasepsql is a regular PostgreSQL client application.
export PATH=/usr/pgsql-9.2/bin:$PATH
The program executable psql
is in the directory /usr/pgsql-9.2/bin
, and that directory is not included in the path by default, so we have to tell our shell (terminal) program where to find psql
. When most packages are installed, they are added to an existing path, such as /usr/local/bin
, but not this program.
So we have to add the program's path to the shell PATH variable if we do not want to have to type the complete path to the program every time we execute it.
This line should typically be added to theshell startup script, which for the bash shell will be in the file ~/.bashrc
.
perhaps psql isn't in the PATH
of the postgres user. Use the locate command to find where psql is and ensure that it's path is in the PATH
for the postgres user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With