psql: command not found Mac

后端 未结 11 803
清酒与你
清酒与你 2021-01-29 22:16

I installed PostgreSQL via the graphical install on http://www.postgresql.org/download/macosx/

I see it in my applications and also have the psql terminal in my applicat

11条回答
  •  说谎
    说谎 (楼主)
    2021-01-29 22:20

    If Postgresql was downloaded from official website. After installation, running these commands helped me resolve the psql issue.

    Go to your home directory with cd ~

    In your home directory, run ls -a. Edit the .bash_profile file with vim

    vi .bash_profile opens the vim editor.

    Insert by pressing i on the editor.

    Add export PATH=$PATH:/Applications/Postgres.app/Contents/Versions//bin

    The Version Number refers to the version number of the postgresql installed on your local machine. In my case, version 12 was installed, so I inputed

    export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/12/bin .

    Press the esc key and press :wq to exit the editor.

    Enter source .bash_profile in your terminal to read and execute the content of a file just passed as an argument in the current shell script.

    Run psql

    terminal result

    In summary:

    • cd ~
    • vi .bash_profile
    • export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/12/bin Take note of the version number
    • exit vim
    • source .bash_profile
    • psql Works

提交回复
热议问题