Обсуждение: I lost my password
After installing PostgreSQL I lost the password, how can I recover it?
On 2015-07-26 20:51, papa@arbolone.ca wrote: > After installing PostgreSQL I lost the password, how can I recover it? Assuming you have "local" login configured (which is the default), you can su to the postgres user (or whichever is configured in pg_hba.conf) and login with psql directly without being challenged for a password. -- http://yves.zioup.com gpg: 4096R/32B0F416
On 07/26/2015 07:51 PM, papa@arbolone.ca wrote: > After installing PostgreSQL I lost the password, how can I recover it? What OS? How did you install? What password are you talking about? Assuming you are talking about a Postgres password, take a look at: http://www.postgresql.org/docs/9.4/interactive/auth-pg-hba-conf.html From there you can set the local connection to trust and then access Postgres. From there you can reset the password using ALTER USER: http://www.postgresql.org/docs/9.4/interactive/sql-alteruser.html -- Adrian Klaver adrian.klaver@aklaver.com
Which password? What operating system (Linux, Windows, Mac)? If you are on Linux, what I do is an "sudo su postgres-" to switch to the "postgres" user, which does not (since I'm "root" via sudo) require a password to do.
On Sun, Jul 26, 2015 at 9:51 PM, <papa@arbolone.ca> wrote:
After installing PostgreSQL I lost the password, how can I recover it?
Schrodinger's backup: The condition of any backup is unknown until a restore is attempted.
Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.
He's about as useful as a wax frying pan.
10 to the 12th power microphones = 1 Megaphone
Maranatha! <><
John McKown
10 to the 12th power microphones = 1 Megaphone
Maranatha! <><
John McKown
I am using windows 8.1 and what I believe to be the latest version of posgresql from postgresql.org. Would it be better to reinstall postgresql? -----Original Message----- From: Adrian Klaver Sent: Sunday, July 26, 2015 11:01 PM To: papa@arbolone.ca ; PostGreSQL MailingList Subject: Re: [GENERAL] I lost my password On 07/26/2015 07:51 PM, papa@arbolone.ca wrote: > After installing PostgreSQL I lost the password, how can I recover it? What OS? How did you install? What password are you talking about? Assuming you are talking about a Postgres password, take a look at: http://www.postgresql.org/docs/9.4/interactive/auth-pg-hba-conf.html From there you can set the local connection to trust and then access Postgres. From there you can reset the password using ALTER USER: http://www.postgresql.org/docs/9.4/interactive/sql-alteruser.html -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
On 07/26/2015 08:05 PM, papa@arbolone.ca wrote: > I am using windows 8.1 and what I believe to be the latest version of > posgresql from postgresql.org. > Would it be better to reinstall postgresql? So what password are you talking about? I doubt this requires reinstalling. > > -----Original Message----- From: Adrian Klaver > Sent: Sunday, July 26, 2015 11:01 PM > To: papa@arbolone.ca ; PostGreSQL MailingList > Subject: Re: [GENERAL] I lost my password > > On 07/26/2015 07:51 PM, papa@arbolone.ca wrote: >> After installing PostgreSQL I lost the password, how can I recover it? > > What OS? > > How did you install? > > What password are you talking about? > > Assuming you are talking about a Postgres password, take a look at: > > http://www.postgresql.org/docs/9.4/interactive/auth-pg-hba-conf.html > > From there you can set the local connection to trust and then access > Postgres. From there you can reset the password using ALTER USER: > > http://www.postgresql.org/docs/9.4/interactive/sql-alteruser.html > > -- Adrian Klaver adrian.klaver@aklaver.com
OK, I think I should tell you folks that I am a newbie. I am using postgresql to learn the SQL for the purpose of learning storing the data in my c++ application. I have near zero knowledge of SQL or PostgreSQL for that matter. When I type C:\pgsql, I am asked to entered a password, but I don't recall the any passwords I might've set up at installation time. thanks -----Original Message----- From: Adrian Klaver Sent: Sunday, July 26, 2015 11:09 PM To: papa@arbolone.ca ; PostGreSQL MailingList Subject: Re: [GENERAL] I lost my password On 07/26/2015 08:05 PM, papa@arbolone.ca wrote: > I am using windows 8.1 and what I believe to be the latest version of > posgresql from postgresql.org. > Would it be better to reinstall postgresql? So what password are you talking about? I doubt this requires reinstalling. > > -----Original Message----- From: Adrian Klaver > Sent: Sunday, July 26, 2015 11:01 PM > To: papa@arbolone.ca ; PostGreSQL MailingList > Subject: Re: [GENERAL] I lost my password > > On 07/26/2015 07:51 PM, papa@arbolone.ca wrote: >> After installing PostgreSQL I lost the password, how can I recover it? > > What OS? > > How did you install? > > What password are you talking about? > > Assuming you are talking about a Postgres password, take a look at: > > http://www.postgresql.org/docs/9.4/interactive/auth-pg-hba-conf.html > > From there you can set the local connection to trust and then access > Postgres. From there you can reset the password using ALTER USER: > > http://www.postgresql.org/docs/9.4/interactive/sql-alteruser.html > > -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
On 07/26/2015 08:15 PM, papa@arbolone.ca wrote: > OK, I think I should tell you folks that I am a newbie. I am using > postgresql to learn the SQL for the purpose of learning storing the data > in my c++ application. I have near zero knowledge of SQL or PostgreSQL > for that matter. > When I type C:\pgsql, I am asked to entered a password, but I don't > recall the any passwords I might've set up at installation time. Well I do not use Windows much and not all for Postgres so I am at bit of lose here. I did find this: http://www.enterprisedb.com/docs/en/9.3/pginstguide/PostgreSQL_Installation_Guide-07.htm#P138_8268 which indicates a password is asked for in the install. You have no recollection of that being asked or a clue as to what password you may have used? Since the password is used for both the database and the service account and assuming you have not actually done anything with the database, I take back my earlier comment about not reinstalling. It might be easier to do that then going through all the steps necessary to reset in place, given that you are just starting out. > > thanks > > -----Original Message----- From: Adrian Klaver > Sent: Sunday, July 26, 2015 11:09 PM > To: papa@arbolone.ca ; PostGreSQL MailingList > Subject: Re: [GENERAL] I lost my password > > On 07/26/2015 08:05 PM, papa@arbolone.ca wrote: >> I am using windows 8.1 and what I believe to be the latest version of >> posgresql from postgresql.org. >> Would it be better to reinstall postgresql? > > So what password are you talking about? > > I doubt this requires reinstalling. >> >> -----Original Message----- From: Adrian Klaver >> Sent: Sunday, July 26, 2015 11:01 PM >> To: papa@arbolone.ca ; PostGreSQL MailingList >> Subject: Re: [GENERAL] I lost my password >> >> On 07/26/2015 07:51 PM, papa@arbolone.ca wrote: >>> After installing PostgreSQL I lost the password, how can I recover it? >> >> What OS? >> >> How did you install? >> >> What password are you talking about? >> >> Assuming you are talking about a Postgres password, take a look at: >> >> http://www.postgresql.org/docs/9.4/interactive/auth-pg-hba-conf.html >> >> From there you can set the local connection to trust and then access >> Postgres. From there you can reset the password using ALTER USER: >> >> http://www.postgresql.org/docs/9.4/interactive/sql-alteruser.html >> >> > > -- Adrian Klaver adrian.klaver@aklaver.com
After removing PostgreSQL and manually deleting all the other files installed by it I reinstalled PostgreSQL, I started the cmd.exe and typed psql, asked me for the password, entered it, but to no avail. I took notes of all the information I entered during the installation, so this time I'd be sure of the password. Now I know that the problem resides in the PostgreSQL, this makes it easier to trace the problem; since human error can be out of the way. -----Original Message----- From: Adrian Klaver Sent: Monday, July 27, 2015 12:12 AM To: papa@arbolone.ca ; PostGreSQL MailingList Subject: Re: [GENERAL] I lost my password On 07/26/2015 08:15 PM, papa@arbolone.ca wrote: > OK, I think I should tell you folks that I am a newbie. I am using > postgresql to learn the SQL for the purpose of learning storing the data > in my c++ application. I have near zero knowledge of SQL or PostgreSQL > for that matter. > When I type C:\pgsql, I am asked to entered a password, but I don't > recall the any passwords I might've set up at installation time. Well I do not use Windows much and not all for Postgres so I am at bit of lose here. I did find this: http://www.enterprisedb.com/docs/en/9.3/pginstguide/PostgreSQL_Installation_Guide-07.htm#P138_8268 which indicates a password is asked for in the install. You have no recollection of that being asked or a clue as to what password you may have used? Since the password is used for both the database and the service account and assuming you have not actually done anything with the database, I take back my earlier comment about not reinstalling. It might be easier to do that then going through all the steps necessary to reset in place, given that you are just starting out. > > thanks > > -----Original Message----- From: Adrian Klaver > Sent: Sunday, July 26, 2015 11:09 PM > To: papa@arbolone.ca ; PostGreSQL MailingList > Subject: Re: [GENERAL] I lost my password > > On 07/26/2015 08:05 PM, papa@arbolone.ca wrote: >> I am using windows 8.1 and what I believe to be the latest version of >> posgresql from postgresql.org. >> Would it be better to reinstall postgresql? > > So what password are you talking about? > > I doubt this requires reinstalling. >> >> -----Original Message----- From: Adrian Klaver >> Sent: Sunday, July 26, 2015 11:01 PM >> To: papa@arbolone.ca ; PostGreSQL MailingList >> Subject: Re: [GENERAL] I lost my password >> >> On 07/26/2015 07:51 PM, papa@arbolone.ca wrote: >>> After installing PostgreSQL I lost the password, how can I recover it? >> >> What OS? >> >> How did you install? >> >> What password are you talking about? >> >> Assuming you are talking about a Postgres password, take a look at: >> >> http://www.postgresql.org/docs/9.4/interactive/auth-pg-hba-conf.html >> >> From there you can set the local connection to trust and then access >> Postgres. From there you can reset the password using ALTER USER: >> >> http://www.postgresql.org/docs/9.4/interactive/sql-alteruser.html >> >> > > -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
On 27/07/2015 04:15, papa@arbolone.ca wrote: > OK, I think I should tell you folks that I am a newbie. I am using > postgresql to learn the SQL for the purpose of learning storing the data > in my c++ application. I have near zero knowledge of SQL or PostgreSQL > for that matter. > When I type C:\pgsql, I am asked to entered a password, but I don't > recall the any passwords I might've set up at installation time. Hello there, Adrian's advice about re-installing is probably the easiest way to do it. However, here's another route, just for completeness (I'm assuming that you're installing on your own laptop or similar, not a server): Find the file pg_hba.conf in the data directory. Look for a "host" line like this: host all all 127.0.0.1/32 md5 Change "md5" to "trust", save the file and re-start the PostgreSQL service. You should then be able to connect without a password: psql -U postgres NB - If you don't specify a Postgres user with -U, Postgres assumes that you're connecting as the current operating system user. You can then reset the password for the user "postgres" (or whatever user you used to connect): alter role postgres with password 'whatever'; Don't forget to edit pg_hba.conf once again and set "trust" back to "md5' (and re-start the service). Finally, note that the "postgres" user is the super-user, so the usual caveats apply... better to create another ordinary user for normal connections. I hope this helps, Ray. -- Raymond O'Donnell :: Galway :: Ireland rod@iol.ie
On 07/27/2015 06:22 AM, papa@arbolone.ca wrote: > After removing PostgreSQL and manually deleting all the other files > installed by it I reinstalled PostgreSQL, I started the cmd.exe and > typed psql, asked me for the password, entered it, but to no avail. > I took notes of all the information I entered during the installation, > so this time I'd be sure of the password. Now I know that the problem > resides in the PostgreSQL, this makes it easier to trace the problem; > since human error can be out of the way. Can you show that actual psql command line you are using? If not what user are you connecting as? The password that is set up is for the Postgres superuser 'postgres', so you would need to log in via psql using that user. > > > -----Original Message----- From: Adrian Klaver > Sent: Monday, July 27, 2015 12:12 AM > To: papa@arbolone.ca ; PostGreSQL MailingList > Subject: Re: [GENERAL] I lost my password > > On 07/26/2015 08:15 PM, papa@arbolone.ca wrote: >> OK, I think I should tell you folks that I am a newbie. I am using >> postgresql to learn the SQL for the purpose of learning storing the data >> in my c++ application. I have near zero knowledge of SQL or PostgreSQL >> for that matter. >> When I type C:\pgsql, I am asked to entered a password, but I don't >> recall the any passwords I might've set up at installation time. > > Well I do not use Windows much and not all for Postgres so I am at bit > of lose here. I did find this: > > http://www.enterprisedb.com/docs/en/9.3/pginstguide/PostgreSQL_Installation_Guide-07.htm#P138_8268 > > > which indicates a password is asked for in the install. > > You have no recollection of that being asked or a clue as to what > password you may have used? > > Since the password is used for both the database and the service account > and assuming you have not actually done anything with the database, I > take back my earlier comment about not reinstalling. It might be easier > to do that then going through all the steps necessary to reset in place, > given that you are just starting out. > >> >> thanks >> >> -----Original Message----- From: Adrian Klaver >> Sent: Sunday, July 26, 2015 11:09 PM >> To: papa@arbolone.ca ; PostGreSQL MailingList >> Subject: Re: [GENERAL] I lost my password >> >> On 07/26/2015 08:05 PM, papa@arbolone.ca wrote: >>> I am using windows 8.1 and what I believe to be the latest version of >>> posgresql from postgresql.org. >>> Would it be better to reinstall postgresql? >> >> So what password are you talking about? >> >> I doubt this requires reinstalling. >>> >>> -----Original Message----- From: Adrian Klaver >>> Sent: Sunday, July 26, 2015 11:01 PM >>> To: papa@arbolone.ca ; PostGreSQL MailingList >>> Subject: Re: [GENERAL] I lost my password >>> >>> On 07/26/2015 07:51 PM, papa@arbolone.ca wrote: >>>> After installing PostgreSQL I lost the password, how can I recover it? >>> >>> What OS? >>> >>> How did you install? >>> >>> What password are you talking about? >>> >>> Assuming you are talking about a Postgres password, take a look at: >>> >>> http://www.postgresql.org/docs/9.4/interactive/auth-pg-hba-conf.html >>> >>> From there you can set the local connection to trust and then access >>> Postgres. From there you can reset the password using ALTER USER: >>> >>> http://www.postgresql.org/docs/9.4/interactive/sql-alteruser.html >>> >>> >> >> > > -- Adrian Klaver adrian.klaver@aklaver.com
It worked! Thanks kids, that was awesome! One last question, is there a tutorial about accessing the back end using c++ Again, thanks soooo much! -----Original Message----- From: Raymond O'Donnell Sent: Monday, July 27, 2015 9:28 AM To: papa@arbolone.ca ; Adrian Klaver ; PostGreSQL MailingList Subject: Re: [GENERAL] I lost my password On 27/07/2015 04:15, papa@arbolone.ca wrote: > OK, I think I should tell you folks that I am a newbie. I am using > postgresql to learn the SQL for the purpose of learning storing the data > in my c++ application. I have near zero knowledge of SQL or PostgreSQL > for that matter. > When I type C:\pgsql, I am asked to entered a password, but I don't > recall the any passwords I might've set up at installation time. Hello there, Adrian's advice about re-installing is probably the easiest way to do it. However, here's another route, just for completeness (I'm assuming that you're installing on your own laptop or similar, not a server): Find the file pg_hba.conf in the data directory. Look for a "host" line like this: host all all 127.0.0.1/32 md5 Change "md5" to "trust", save the file and re-start the PostgreSQL service. You should then be able to connect without a password: psql -U postgres NB - If you don't specify a Postgres user with -U, Postgres assumes that you're connecting as the current operating system user. You can then reset the password for the user "postgres" (or whatever user you used to connect): alter role postgres with password 'whatever'; Don't forget to edit pg_hba.conf once again and set "trust" back to "md5' (and re-start the service). Finally, note that the "postgres" user is the super-user, so the usual caveats apply... better to create another ordinary user for normal connections. I hope this helps, Ray. -- Raymond O'Donnell :: Galway :: Ireland rod@iol.ie
On 27/07/2015 14:54, papa@arbolone.ca wrote: > It worked! > Thanks kids, that was awesome! Glad it worked. It's a while since I've been called a kid! :-) > One last question, is there a tutorial about accessing the back end > using c++ I've done it using Qt, and there are tons of documentation and examples out there - Google is your friend. Qt's own documentation is very good. For plain C, read PostgreSQL's own docs: http://www.postgresql.org/docs/9.4/static/libpq.html Ray. -- Raymond O'Donnell :: Galway :: Ireland rod@iol.ie