Setting Windows PATH for Postgres tools
If, after installing PostgreSQL, you face “psql not recognized as an internal or external command” error when you try to run psql from command prompt, then most probably all you need to do to solve this problem is to add the Postgres’s bin directory to the PATH system variable (the PATH is a system variable which allows Windows with the help of the Command prompt or the Terminal window find executables).
In this blog post, we’ll share seven simple steps that describe how to add the folder to the Windows 10 PATH variable.
Step 1. Run Windows Search on your Windows 10 machine by pressing WIN+S. You will see the Search Textbox.
Go to the “Advanced” tab and click on the “Environment Variables” button at the bottom. The “Performance,” “User Profiles,” and “Startup and Recovery” options can also be set in this tab.
Step 4. The “Environment Variables” window will be opened. This is divided into two boxes with User variables and System variables – where all variables and their values are displayed.
Find the “Path” variables in the System variables box, as shown in the screenshot above.
Step 5. Double click on the “Path” variable.
The list with all Path variables will be opened, where the Path variables can be edited, added, and deleted.
March 26, 2020 @ 4:31 pm
Thank you!! Exactly what I needed.
April 16, 2020 @ 12:55 am
Awesome. This is the most simple, straightforward answer I could find. Thanks.
April 22, 2020 @ 5:10 am
Thanks for the heads up! It is the best solution I have seen so far.
May 7, 2020 @ 3:34 pm
thank you very much! i have been stuck for a long time until I found this. thank you again!
June 24, 2020 @ 3:07 am
Thanks a lot for this, I was stuck a whole day on it and you solved my problem in less than 20 min.
July 1, 2020 @ 7:32 am
Thanks You :)
Very Helpful and Informative :)
July 3, 2020 @ 2:16 pm
I’m really hoping you can help me! I did this step with no issue and my command prompt can open the psql when I do psql -U postgres and then enter the postgres password I set.
I cannot however just enter psql and go. It is showing my normal C drive user acc as the default e.g. C:\Users\Me> and then if I type psql, it asks for my user password which does not work.
What can I do? On postgres 12. Thank you
July 6, 2020 @ 6:06 pm
Hi @Lebene.
I am actually seeking for the same solution. But i guess so far, the above may not work as the database superuser is the default postgres. So I guess to interact with any existing database besides postgres (which you may have created), you have to login to postgres first, then connect to the database using \c .
July 19, 2020 @ 9:39 pm
Is this the default system variable in Windows 10? Because I accidentally deleted the value of path, and PATHEXT, and restarted the computer, the computer restore did not open. Now the command window CMD input other commands are not internal or internal commands. What should I do?
August 20, 2020 @ 7:02 pm
Thanks. Worked!
October 20, 2020 @ 9:15 am
Thank you!
December 1, 2020 @ 6:58 am
Brilliant, the screenshots really helped. Thanks
January 16, 2021 @ 2:13 am
This works very well.