Emacs, sql-mode, Postgresql and password entry

I am trying to connect to PostgreSQL DB through Emacs using sql mode. I run Emacs, the Mx sql-postgres command, and it asks for User, Databases, and Server, but not for password. An empty buffer opens and no matter what I write, I get:

 the Password for user james: psql: FATAL: password authentication failed for user "james" 

I can login using psql. I am running GNU Emacs 24.4.1 on Linux Antergos, PostgreSQL 9.3.5.

Thanks..

+5
source share
5 answers

Kevin's answer provides an interactive solution.

Otherwise, you should use a non-interactive authentication method (for example, a .pgpass file).


My initial (and incorrect) suggestion was to enable the password customize-option in Mx customize-option RET sql-postgres-login-params RET .

The sql-*-login-params variables (and related widgets) are generalized across all types of databases; but not all of these options apply to all databases.

If applicable, passwords are read by Emacs and then used on the command line. However, psql does not allow you to enter a password as part of the command, so Emacs cannot use this approach here. This is why the password option is disabled for postgres login options.

+5
source

In case someone else is looking at me, I solved this by calling the invisible and typing the password after the sql-postgres command completed. Emacs version 24.5.1.

  • Initiate a postgres connection
  • On a blank screen Mx send-invisible
  • Enter password.
  • Profit
+8
source

I solved this temporarily by creating a .pgpass file where I saved my connection credentials. I donโ€™t like this, and I would like to get a solution that requires a password when entering the system.

+3
source

I have this problem too. If you go to an empty buffer and press enter, will you get a password there? I do, and when I enter the password, the mode works fine.

+1
source

works for me by setting the environment variable PGPASSWORD , for example. (setenv "PGPASSWORD" "whatever your password is")

+1
source

Source: https://habr.com/ru/post/1205971/


All Articles