download postgressql application
Steps to Add psql to PATH
1. Edit Your Shell Configuration
Since you're using
zsh, add the directory to your PATH in the ~/.zshrc file:vim ~/.zshrc
Add the following line at the end of the file:
export PATH=$PATH:/Library/PostgreSQL/17/bi
2. Apply Changes
Reload your shell configuration:
.source ~/.zshrc
3. Verify psql Command
Check if
psql is now available:psql --ve
You should see the version of
psql displayed.4. Connect to PostgreSQL
Now you can try connecting to your PostgreSQL database:
psql -U devanshpc
1. List Existing Databases
Connect to PostgreSQL and list all databases:
psql -U devanshpc -l
This will show a list of databases. Look for the database you want to connect to, such as
gradnet.2. Connect to the Correct Database
If the database
gradnet exists, specify it when connecting:psql -U devanshpc -d grad
3. Create the Database (If Missing)
If
gradnet does not exist in the list of databases, you need to create it:- Connect to PostgreSQL's default
postgresdatabase:
psql -U devanshpc -d postgres
- Create the
gradnetdatabase:
CREATE DATABASE gradnet;
- Grant privileges to the user (if needed):
GRANT ALL PRIVILEGES ON DATABASE gradnet TO devanshpc;
- Exit the
psqlprompt:
\q
4. Connecting to the Database
After creating the
gradnet database (if necessary), connect to it:psql -U devanshpc -d gradnet