psql: FATAL: password authentication failed for user "akhil" - postgresql

I have installed PostgreSQL 10.0 on my Windows 10, during the installation it asked me to enter a password for root user and I have created one. I wanted to run it over the command line and have set environment variables, but when i try to launch it by typing
C:\Users\akhil\Documents\Flask Examples\postsql>psql sample.sql
Password:
psql: FATAL: password authentication failed for user "akhil"
I've seen some solutions to change the pg_hba.conf file but It couln't help me.
(update)
I've also tried to create a user id but it shows the same error
createuser akhil
Password:
createuser: could not connect to database postgres: FATAL: password authentication failed for user "akhil"

This should help you get in to your database.
psql postgres://username:password#ip_address/database < sample.sql

Related

Password authentication failed for user

I am having a problem trying to run psql on my MacOs. The psql command returns the following error:
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: password authentication failed for user "luicruz"
How could I fix this?
I try to put my sudo password when the terminal request me the password, but it didn't work. The only password that works is for the default user "postgres" that I set the password when I install the app on my system.
I don't know why the user 'luicruz' was automatically created, I didn't create this user or set a password for this user.
And now I can't use the psql command.
Below is an image showing the login/Group roules of the Pg Admin 4 and also the return of the commands in the terminal
The problem is that the psql command needs to be used in addition to the database name, and I didn't know that. After creating the database, I was able to use the command apart from the psql command.

PostgreSQL: password authentification failed on macOS(Mojave)

I just installed postgres through Terminal and when I try to createdb "test" I allways get this error:
createdb: could not connect to database template1: FATAL: password authentication failed for user ""
I know there are a few threads already on this topic but nothing works. Most suggestions were to update "pg_hba.conf" but I'm doing it wrong or there is something else... I also tried to remove the postgres password but it doesn't work... nothing seems to work...

fatal: password authentication failed for user "user"

C:\Program Files\PostgreSQL\10\bin>psql -- U "user"
Password:
psql: FATAL: password authentication failed for user "user"
I'm getting the above error when trying to run postgresql from cmd line on windows. However, when I run it from the start menu (using the gui) the password works fine. I'm on a laptop logged in as a user. My IT dept set up this role to have most admin privileges, but not all. So I installed the software as a user when I created the password. I want to use createdb db_name on the command line. What is the proper way to access posgreSQL from windows command line? How do I get to createdb and beyong the authentication issue? I tried changing the pg_hba.conf file also and that didn't work.
C:\Program Files\PostgreSQL\10\bin>psql -U username template1
username is your user to login
template1 is default database

Postgres won't let me log in

I am trying to use postgres but when I type:
sudo -u postgres psql
I get prompted for a password, which I've tried 'postgres' and my root password. I get this error:
psql: FATAL: password authentication failed for user "postgres"
How can I reset postgres to not prompt for a password? I installed with homebrew, and I'd be just as happy uninstalling and reinstalling as changing the permissions.
I tried updating pg_hba.conf with this line to no success:
local all trust
The line in pg_hba.conf should be local all all trust.

postgresql password authentication failure

I have installed PostreSQL, I have the Heroku toolbox, and I'm still trying to just get started.
From my Windows command prompt, I type psql and it asks for a password, and I type in the one I provided when installing PSQL, and it still gives me:
C:\Users\Tina\Desktop\FriendActivity>psql
Password:
psql: FATAL: password authentication failed for user "Tina"
I have even tried:
C:\Users\Tina\Desktop\FriendActivity>psql -U postgres
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
This is a fresh install. First time trying to use it.
I was trying to follow these steps here:
https://devcenter.heroku.com/articles/heroku-postgresql#local-setup
but
export DATABASE_URL=postgres:///$(whoami)
does not work:
C:\Users\Tina\Desktop\FriendActivity>export DATABASE_URL=postgres:///$(whoami)
'export' is not recognized as an internal or external command,
operable program or batch file.
I have been trying to get this set up to use for a class project that uses a database for a few days now... and I cant seem to get this to work.
the project we are working on is here:
https://github.com/rwprice31/FriendActivity
My part is getting the database functionality working.
You are following instructions written for Linux or Mac OS X. They will not work on Windows.
The Windows equivalent of:
export DATABASE_URL=postgres:///$(whoami)
is
set DATABASE_URL=postgres://localhost/databasename
where you should replace databasename with the name of the database you wish to connect to.
As for:
> psql -U postgres
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
I can only assume that you made a mistake entering the password when you set it up, or you had an old PostgreSQL data directory already in place from a past install.
Either way, you'll need to reset the password. There are many instructions here for doing that, so I won't repeat them.
Regarding:
>psql
Password:
psql: FATAL: password authentication failed for user "Tina"
Presumably there is no user named Tina in PostgreSQL. The installer would usually only create a postgres user when installed.