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
Related
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.
EDIT: WINDOWS: Yes Windows. Do not redirect me to answers that specify sudo-ing because, hey, I can't sudo on Windows.
I have just done a fresh install of postgres 11 on Windows and I am getting
C:\Users\J\Documents\Development>psql -U postgres
psql: FATAL: password authentication failed for user "postgres"
password retrieved from file "C:\Users\J\AppData\Roaming/postgresql/pgpass.conf"
Note that I do not get an opportunity to enter a password - i.e. I do NOT get a password prompt. There is a password in the pgpass.conf file. I am running the cmd.exe box as Administrator.
There is a link to psql in the folder created at installation but that is no good either. It identically does not ask for a password.
Any ideas? Thanks in advance.
The password file is documented.
To get a password prompt, locate the file in %APPDATA%\postgresql\pgpass.conf and delete it.
It was probably created automatically by pgAdmin.
If there is an entry in the password file that matches your login, you won't be prompted, and the password is taken from the file. If you delete the file, you will be prompted for a password (if pg_hba.conf is configured accordingly).
I just installed PostgreSQL on my computer. In some stage of the installation I was requested to define a password (but was not requested to set user). The installation completed successfully. Now I changed directory to C:\Program Files\PostgreSQL\11\bin and write in command line
psql
I got a request for password for user xxx that I use to login to Windows. I tried to enter the password I had defined, but no symbol is shown and the cursor doesn't move. After "Enter" I get message
psql: FATAL: password authentication failed for user "xxx"
So I think that something wrong but I don't know how to fix that.
Login as database user postgres rather than using the default (the user of the same name as the operating system user):
psql -U postgres
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
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.