0

I am new to PostgreSQL and before I start learning got stuck in the password; I have forgotten my password to PostgresSQL 13 path when I use pdAdmin tool.

I use mac. Apologies for basic questions.

I went through multiple articles, videos but I am unable to through different steps.

Steps I did:

  • Downloaded PostgreSQL 13, logged into pgAdmin, forgot password to PostgreSQL 13 db
  • Found the "pg_hba.conf" and edited the method from "md5" to "trust"

Steps I am unable to proceed and stuck:

  • Restart the postgresql service (where and how do I do this? via launching Terminal?)
  • Start psql session as postgres (how to launch? I searched the psql via search. When I entered "psql -U postgres", its asking for "Database" and "Port (5432)" and "Username". I am unaware to find these"

This is where I am unable to go to next step to use ALTER USER command to reset.

I went through this but when I enter the command "sudo -u user_name psql db_name", its asking for all information above which I don't have knowledge yet. Same as above points where I am getting stuck.

postgreSQL 13

psql

Many thanks in advance.

Girish
  • 35
  • 1
  • 11

1 Answers1

-1

If you installed Postgres using brew (That's most common case)..

To access postgres

# psql postgres

postgres is the database name, and after this you will be logged into psql and will see postgres db. You can switch to your database as -

\c <your-db-name-here>

To start/stop/restart

brew services start postgresql
brew services stop postgresql
brew services restart postgresql

If you did not install using brew and want to do so -

brew install postgres
Ravi Kumar Gupta
  • 1,698
  • 2
  • 22
  • 38