psql command not found - Mac
How to Install psql Command on Mac
If you are trying to use the psql command on your Mac and find that it is not available, it is because psql is a command-line interface for interacting with PostgreSQL databases, and it is not included by default on macOS.
Installation Steps
To install the psql command on your Mac, follow these steps:
-
Install PostgreSQL: The
psqlcommand is part of the PostgreSQL database system. You can download and install PostgreSQL for macOS from the official website: PostgreSQL Downloads. -
Add psql to PATH: After installing PostgreSQL, you will need to add the PostgreSQL bin directory to your PATH. This can be done by adding the following line to your
.bash_profileor.zshrcfile:export PATH=$PATH:/Library/PostgreSQL/{version}/binReplace
{version}with the actual version number of PostgreSQL you installed. -
Restart Terminal: After making the PATH changes, restart your terminal or run
source ~/.bash_profileorsource ~/.zshrcto apply the changes. -
Verify Installation: You can now test if the
psqlcommand is available by running:psql --version
Compatibility Note
If any of the commands or steps mentioned above are not compatible with your macOS version or setup, you can explore alternative methods such as using Homebrew to install PostgreSQL or adjusting the PATH based on your installation directory.
Conclusion
By following these steps, you should now have the psql command available on your Mac, allowing you to interact with PostgreSQL databases from the command line.