Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (180 points)
edited by

I had installed the PostgreSQL and it is working fine. However, when I am trying to restore a backup I am getting 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? 

1 Answer

0 votes
by (12.7k points)
export PATH=/usr/pgsql-9.2/bin:$PATH

The executable program psql is in the directory /usr/pgsql-9.2/bin, and that directory isn't included in the path by default, so we have to tell our shell (terminal) program where to find psql. When most of the packages are installed, they are added to an existing path, such as /usr/local/bin, but not this program.

So we need 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 the shell startup script, which for the bash shell will be in the file ~/.bashrc

Interested in SQL ? Check out this SQL Certification by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Nov 21, 2020 in SQL by Appu (6.1k points)
0 votes
2 answers
asked Jul 23, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...