I am not a postgres guy I hardly know anything about it but when the duty calls you have to do anything to get it working.
Yes that's possible :) a very simple trick can do this, all you have to do is go to
'/usr/lib/pgsql/data/' location and edit the pg_hba.conf file.
So, exactly what to do, just follow below steps :
> vi /usr/lib/pgsql/data/pg_hba.conf
> 'press insert key on keyboard'
> search for something like
local all all ident
> change this to
local all postgres trust
> press 'Esc' key on keyboard and type ':wq'
which is nothing but telling the editor to write and quite
Step 3. Start postgres service
> service postgres start
Step 4. Now try to login into the postgres again
> su - postgres
So now I faced few problems with postgreSQL I decided to complete the beginners guide to it.
For now I am referring to PostgreSQL : Up and Running book you can get it too from any online stores. You can get some good deals on ebay, amazon or flipkart like sites.
So today duty called :) where I need to take the dump of a postgres database and import it on another machine now the biggest challenge was logging into the postgres and run the command when you don't know the root user password and the sad thing was I installed that postgres long back but didn't kept the password.
Now I have to first find the password (which was not possible) or find a way to access it somehow.
Luckily I found one solution to my problem :) . According to the article we can allow any user to do operation without any password, okayyy this was interesting. I tried them and bingo it worked :)
So I would like to share those steps here so that it will help some needful like me.
Step 1. Stop the postgres.
> service postgres stop
Step 2. Reset the authentication mechanism (assuming defaults are already being used)
Yes that's possible :) a very simple trick can do this, all you have to do is go to
'/usr/lib/pgsql/data/' location and edit the pg_hba.conf file.
So, exactly what to do, just follow below steps :
> vi /usr/lib/pgsql/data/pg_hba.conf
> 'press insert key on keyboard'
> search for something like
local all all ident
> change this to
local all postgres trust
> press 'Esc' key on keyboard and type ':wq'
which is nothing but telling the editor to write and quite
Step 3. Start postgres service
> service postgres start
Step 4. Now try to login into the postgres again
> su - postgres
and yupieeee it's done
now you can reset your root password and and undo the changes that we did for authentication mechanism.
and now you have a user with password.
Tell me if this helped :)
So now I faced few problems with postgreSQL I decided to complete the beginners guide to it.
For now I am referring to PostgreSQL : Up and Running book you can get it too from any online stores. You can get some good deals on ebay, amazon or flipkart like sites.
Comments
Post a Comment
.