Password authentication fails when trying to connect to postgresql from clojure with jdbc -
i'm learning web development in clojure , i'm not @ expert in either postgresql or jdbc.
i'm going through "web development clojure" book , i'm stuck because cannot connect postgresql database, although believe have followed tutorial step step.
i connected psql with
sudo -u postgres psql
then created admin user password 'admin'
postgres=# create user admin password 'admin'; create role
then created database named reporting :
postgres=# create database reporting owner admin; create database
no complaints far.
then clojure code, attempt connect database , create table :
(ns reporting-example.models.db (:require [clojure.java.jdbc :as sql])) ;defining db connection (def db {:subprotocol "postgresql" :subname "//localhost/reporting" :user "admin" :password "admin"}) ;function creating 'employee' table (defn create-employee-table [] (sql/create-table :employee [:name "varchar(50)"] [:occupation "varchar(50)"] [:place "varchar(50)"] [:country "varchar(50)"]) ) ; trying create table, here's part breaks exception : (sql/with-connection db (create-employee-table))
and i'm getting ugly :
org.postgresql.util.psqlexception: fatal: password authentication failed user "admin"
which not make sense me, credentials seem fine.
i tried above code both counterclockwise repl , leiningen repl. i'm on ubuntu 13.10, if matters.
could explain me doing wrong here? in advance!
since can't connect psql
using same settings there 3 possibilities:
- wrong/typo'd password
- wrong/typo'd username
- you not connecting same server created account on.
to check latter, connect did create account , run
show port;
make sure same specify in app. isn't perfect - 2 pg instances can share port if 1 isn't listening on tcp/ip , has different socket directory - first test.
you should examine postgresql server error logs, may contain more detailed information nature of authentication failure.
Comments
Post a Comment