DEV Community

Gem Cloud
Gem Cloud

Posted on

5 4

Net Core postgreSQL connection string on windows 10

Prepare knowledge:

  • The file “pg_hba.conf” control whether password or not:

Image description

  • Find server port number at pgAdmin4:
    Image description

  • Restart PostgreSQL server:
    typing “services.msc” on Run and Enter key.

Image description

config password Steps:

  • find the file pg_hba.conf;
  • Back it up;
  • place the following line
local all all trust
Enter fullscreen mode Exit fullscreen mode
  • restart your PostgreSQL server

  • you can now connect as any user. Connect as the superuser postgres

>psql -p 5433 -U postgres
Enter fullscreen mode Exit fullscreen mode
  • Reset password ('replace my_user_name with postgres since you are resetting postgres user)
ALTER USER my_user_name with password 'my_secure_password';
ALTER USER postgres with password 'pass@2022';
Enter fullscreen mode Exit fullscreen mode
  • Restore the old pg_hba.conf as it is very dangerous to keep around

  • Restart the server, in order to run with the safe pg_hba.conf.

Result:
The ConnectionString is "Host=localhost;Port=5433;Username=postgres;Password=pass@2022;Database=dvdrental;";

Dos Commands:

>cd C:\Program Files\PostgreSQL\14\bin>
>psql -p 5433 -U postgres
postgres=# ALTER USER postgres with password 'pass@2022';
Enter fullscreen mode Exit fullscreen mode

It worked!
The end!

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay