分类: Mysql/postgreSQL
2011-02-10 15:08:37
These instructions assume you are using PostgreSQL from the Redhat RPMS. On other systems, the location of the configuration files and the name of the administrative user may be different.
As root, become the postgres user.
Open up /var/lib/pgsql/data/pg_hba.conf in your text editor and look for the authentication method for the postgres user. Unless you are connecting to PostgreSQL over the network, it will be a local user, so look for the line starting with that:
Network users would begin with "host" and there would also be an IP address and netmask:
If your system is configured for all users to authenticate in the same way, you see "all" in place of a username.
Note that "md5" may be set to "password" or a number of other options, but you want to make it "ident sameuser". This means you can connect to PostgreSQL as long as you are the user specified.
After you have saved your changes to pg_hba.conf, issue the command 'pg_ctl reload'. You will be able to connect now with psql.
Now reset your password.
Now re-edit pg_hba.conf to set it back to using md5 or password authentication (md5 is more secure). Signal a reload again, then run psql to make sure it is working.