Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres "psql not recognized as an internal or external command"

For Postgres, I keep getting this error multiple times even though I have already set the location of the bin folder to the path variable in Windows 8. Is there something else I'm missing?

(I can't post pictures since I don't have enough reputation)

like image 971
as1216 Avatar asked May 22 '15 16:05

as1216


People also ask

Why is psql not working?

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 ...

Where is psql located Windows?

On Windows, the default data folder is C:\Program Files\PostgreSQL\x.x\data.

Is psql the same as PostgreSQL?

psql is a terminal-based front-end to PostgreSQL. It enables you to type in queries interactively, issue them to PostgreSQL, and see the query results.


2 Answers

Just an update because I was trying it on Windows 10 you do need to set the path to the following: ;C:\Program Files\PostgreSQL\9.5\bin ;C:\Program Files\PostgreSQL\9.5\lib

You can do that either through the CMD by using set PATH [the path] or from my

computer => properties => advanced system settings=> Environment Variables => System Variables

Then search for path.

Important: don't replace the PATHs that are already there just add one beside them as follows ;C:\Program Files\PostgreSQL\9.5\bin ;C:\Program Files\PostgreSQL\9.5\lib

Please note: On windows 10, if you follow this: computer => properties => advanced system settings=> Environment Variables => System Variables> select PATH, you actually get the option to add new row. Click Edit, add the /bin and /lib folder locations and save changes.

Then close your command prompt if it's open and then start it again try psql --version If it gives you an answer then you are good to go if not try echo %PATH% and see if the path you set was added or not and if it's added is it added correctly or not.

Important note:

Replace 9.5 with your current version number. As of 2021, that is 13

like image 89
Shahin Avatar answered Oct 05 '22 08:10

Shahin


Windows 10

It could be that your server doesn't start automatically on windows 10 and you need to start it yourself after setting your Postgresql path using the following command in cmd:

pg_ctl -D "C:\Program Files\PostgreSQL\11.4\data" start 

You need to be inside "C:\Program Files\PostgreSQL\11.4\bin" directory to execute the above command.

EX:

enter image description here

You still need to be inside the bin directory to work with psql

like image 36
Abdel-Raouf Avatar answered Oct 05 '22 07:10

Abdel-Raouf