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 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.
Thank you!! Exactly what I needed.
Awesome. This is the most simple, straightforward answer I could find. Thanks.
Thanks for the heads up! It is the best solution I have seen so far.
thank you very much! i have been stuck for a long time until I found this. thank you again!
Thanks a lot for this, I was stuck a whole day on it and you solved my problem in less than 20 min.
Thanks You :)
Very Helpful and Informative :)
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
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 .
Try this command: psql -U postgres
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?
Thanks. Worked!
Thank you!
Brilliant, the screenshots really helped. Thanks
This works very well.
Thank you so much, exactly what I need
Thank you so much!
Thanks, first of all! All done, I can see the path on my command line when echo %PATH%, but still if I try to type any command using psql the output is the same : ‘psql’ is not recognized as an internal or external command,
operable program or batch file…..what can I do to solve the issue? Thanks
Hi Cornelia,
This issue can happen if:
1. There is no psql.exe utility in the directory that is in the PATH variable
2. The computer hasn’t been restarted after changing the variable
I swear this is making me go insane. I downloaded the psql but i just never get the psql.exe for some reason same for mongodb i just dont get the right files why is that and how can i get it?
Hello Bram,
Official PostgreSQL website recommends downloading binaries from here: https://www.enterprisedb.com/download-postgresql-binaries
Hi, Cornelia. A had the same problem.
The real issue was because the output from the command is bigger than a page and the command prompt had a setting pset pager on
I disabled this setting and the problem was solved.
The command to disable – \pset pager off
Try if it’s still actual
Thank you very much
amazing!
Thanks a lot
That was quite helpful. Thanks!!
Nice, it’s working for me
Really clearly explained and helpful, thanks.
Thank you , that was helpful
I’ve had a problem with pythons pg_config not being on a path. I’ve never worked with this PATH and my whole backend development team of mine has been waiting more than a week to get things fixed for ready for production. I’ve looked everywhere for how to do this and this is one of the only hands-down straight-up examples there for this.
Saved my day, thank you!
Thank you!!
Thank you… it’s short and sweet
THANK YOU
As at the time of writing thic comment, we have Postgres 14 as the current version. So, C:\Program Files\PostgreSQL\11\bin\ will not work, but adding C:\Program Files\PostgreSQL\14\bin\ to your environment variable will.
It is important for you to note the version of your Postgres installed.
Works
This was very helpful
Thanks for this. I have been frustrated all-day
Like everyone before, thank you for this solution
Thank you.
The best solution!
Thank you so much for this help!
Thanks for the guidance!!