Postgres “psql not recognized as an internal or external command”

前端 未结 10 1730
南方客
南方客 2021-02-02 06:07

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

相关标签:
10条回答
  • 2021-02-02 06:13

    Simple solution that hasn't been mentioned on this question: restart your computer after you declare the path variable.

    I always have to restart - the path never updates until I do. And when I do restart, the path always is updated.

    0 讨论(0)
  • 2021-02-02 06:17

    Find your binaries file where it is saved. get the path in terminal mine is

    C:\Users\LENOVO\Documents\postgresql-9.5.21-1-windows-x64-binaries (1)\pgsql\bin
    

    then find your local user data path, it is in mostly

    C:\usr\local\pgsql\data
    

    now all we have to hit the following command in the binary terminal path:

    C:\Users\LENOVO\Documents\postgresql-9.5.21-1-windows-x64-binaries (1)\pgsql\bin>pg_ctl -D "C:\usr\local\pgsql\data" start
    

    done!

    0 讨论(0)
  • 2021-02-02 06:18

    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.

    0 讨论(0)
  • 2021-02-02 06:19

    If you tried all the answers and still spinning your heads, don't forget to change the version with your one which you downloaded.

    For example, don't simply copy paste

    ;C:\Program Files\PostgreSQL\9.5\bin ;C:\Program Files\PostgreSQL\9.5\lib
    

    More clearly,

    ;C:\Program Files\PostgreSQL\[Your Version]\bin ;C:\Program Files\PostgreSQL\[Your Version]\lib
    

    I was spinning my heads. Hope this helps.

    0 讨论(0)
  • 2021-02-02 06:21

    I had your issue and got it working again (on windows 7).

    My setup had actually worked at first. I installed postgres and then set up the system PATH variables with C:\Program Files\PostgreSQL\9.6\bin; C:\Program Files\PostgreSQL\9.6\lib. The psql keyword in the command line gave no errors.

    I deleted the PATH variables above one at a time to test if they were both really needed. Psql continued to work after I deleted the lib path, but stopped working after I deleted the bin path. When I returned bin, it still didn't work, and the same with lib. I closed and reopened the command line between tries, and checked the path. The problem lingered even though the path was identical to how it had been when working. I re-pasted it.

    I uninstalled and reinstalled postgres. The problem lingered. It finally worked after I deleted the spaces between the "; C:..." in the paths and re-saved.

    Not sure if it was really the spaces that were the culprit. Maybe the environment variables just needed to be altered and refreshed after the install.

    I'm also still not sure if both lib and bin paths are needed since there seems to be some kind of lingering memory for old path configurations. I don't want to test it again though.

    0 讨论(0)
  • 2021-02-02 06:28

    Even if it is a little bit late, i solved the PATH problem by removing every space.

    ;C:\Program Files\PostgreSQL\9.5\bin;C:\Program Files\PostgreSQL\9.5\lib
    

    works for me now.

    0 讨论(0)
提交回复
热议问题