[psycopg2] Ident authentication failed for user

运行 manage.py syncdb 时出现下面的错误: psycopg2.OperationalError: FATAL: Ident authentication failed for user "postgres"

找到下面的解决方案

Subject: Re: django and postgres permalink From: Nimrod A. Abing (nimr...@gmail.com) Date: Sep 27, 2007 6:05:10 am List: com.googlegroups.django-users

It's a bad idea to use the 'postgres' user account since this account is the Postgresql superuser account. Which means, with this account it is possible to do some serious damage to the system catalogs. You should create a separate Postgres user account and create a database for it.

First switch to the postgres Unix account, enter your current user's password when prompted:

$ sudo su -s /bin/bash - postgres

Then, when prompted for the password type in the password that you would like to use for this database user:

$ createuser -S -D -R -E -P

Then:

$ createdb -E utf8 -O

Then edit /etc/postgresql/8.2/main/pg_hba.conf and add the following line:

local password

Save the file, then run:

$ pg_ctlcluster 8.2 main reload

Log out of the Unix account.

别忘记重启下postgresql sudo /etc/init.d/postgresql8.4 restart

Comments on old posts like this are closed.