postgresqlemacssql-mode

Emacs, sql-mode, Postgresql and inputing password


I'm trying to connect to a PostgreSQL DB thru Emacs using the sql-mode. I start Emacs, command M-x sql-postgres and it prompts for User, Database and Server but not for the password. An empty buffer opens and whatever I write, I get:

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

I can login using psql, though. I'm running GNU Emacs 24.4.1 in Linux Antergos, PostgreSQL is 9.3.5.

Thanks..


Solution

  • Kevin's answer provides an interactive solution.

    Otherwise you must use a non-interactive method of authenticating (such as a .pgpass file).


    My original (and incorrect) suggestion was to enable the "password" option at M-x customize-option RET sql-postgres-login-params RET.

    The sql-*-login-params variables (and associated customize widgets) are generalised across all database types; but not all of those options are applicable to all of the databases.

    Where applicable, passwords are read by Emacs and then used in the command line. psql doesn't allow the password to be supplied as part of the command, however, so there's no way for Emacs to use this approach here. This is why the password option is disabled for the postgres login params.