Problems connecting to PostgreSQL

Cecil Westerhof Cecil at decebal.nl
Sat Nov 7 18:40:11 EST 2015


I followed http://zetcode.com/db/postgresqlpythontutorial/.

I used:
    sudo -u postgres createuser stressTest
this create the role, but also gave:
    could not change directory to "/root": Permission denied
and I did not get the questions.

Then I used:
    sudo -u postgres createdb stressTest -O stressTest
This gave also:
    could not change directory to "/root": Permission denied

The database is created, but when I execute:
    conn = psycopg2.connect(database = postgres_database, user = 'stressTest')
I get:
    psycopg2.OperationalError: FATAL:  Peer authentication failed for user "stressTest"

What do I need to do to get things working?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof



More information about the Python-list mailing list