Cannot find any tutorials that show what you do when you deleted default postgres user through root.

  1. Created local postgres server through sudo apt-get install postgresql postgresql-contrib. Inside shell, typed psql and was able to initiate db.

  2. Logged into root and deleted postgres account in linux while trying something out. 2a: sudo pkill -KILL -u postgres 2b: sudo userdel postgres

  3. Deleted postgres server. Re-installed. Got user not found when trying to log into postgres user account through shell.

  4. Tried running postgres server through root and got unable to connect to server through shell.

  5. Re-created postgres user account through root: sudo adduser postgres --disabled-password.

  6. Postgres user through root: sudo usermod -a -G sudo postgres

  7. Still getting unable to connect to server: connection refused. Logged into postgres user. No change.

  8. Re-installed postgres. Same error.

Suggestions?

Thanks a bunch.

share|improve this question
1  
Am I right to assume that you don't have any valuable data in the database yet? – OscarJ Mar 2 '16 at 0:22
    
@OscarJ Yeah, no valuable data. – Johnathan Mar 2 '16 at 1:17
    
The configuration file should tell you in which directory postgres keeps its data. When you uninstall it, it probably doesn't remove that data directory. So unistall, remove the data directory manually, then reinstall. That might work. – OscarJ Mar 2 '16 at 1:20
up vote 1 down vote accepted

You don't exactly need a user who is named postgres, you need a user who owns the data directory, the binaries and configuration files. You should check which uid and gid are now associated with your data directory, then create a user with that specific uid and gid. But check who those id's belong to first. If no user currently has those uid and gid then create a new user with those values:

useradd -u 123 -g 456 postgres

Alternatively, re-create user postgres and assign data directory and binaries to that new user (assuming group postgres still exists):

useradd -G postgres postgres
chown -r postgres:postgres $PGDATA
chown -r postgres:postgres /wherever/bin/is
chown -r postgres:postgres /wherever/conf/is
share|improve this answer
    
Tried pg_lsclusters results in @ Missing argument in printf at /usr/bin/pg_lsclusters line 38. 9.1 main 5432 down /var/lib/postgresql/9.1/main /var/log/postgresql/postgresql-9.1-main.log. – Johnathan Mar 2 '16 at 1:27
    
In the end, I ran into problems trying to figure out who was assigned the GID 26. After playing around for a bit, I finally did everything that you guys mentioned but a new bug then showed up. I decided it was easier to just reinstall the OS from that point. Thanks for the help. – Johnathan Mar 3 '16 at 15:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.