by Kevin Asklund - cPanel Technical Trainer

How to Install Postgres
Note: cPanel requires Postgresql 7.3.x or later. 7.2.x will not work. 1. 2. 3. 4. 5. /scripts/installpostgres WHM Main >> Server Setup >> Postgres Config install postgres pg_hba.conf file log into cPanel and the link to Postgresql should be visible.

How to Reinstall Postgres
From a very old forum post by Nick, augmented by MaryWior 1. 2. check to make sure that your codebase is good 1. /scripts/upcp 2. rpm -qa | grep sql should show that postgresql is > 7.3 make backups if necessary 1. backup databases using pg_dumpall (or whatever method you prefer) 2. move the postgres data directory somewhere else: * mv /var/lib/pgsql /var/lib/ pgsql.old install 1. recreate /var/lib/pgsql with perms of 700 owned by postgres:postgres 2. /scripts/installpostgres if you preserved in step one, restore now Log into WHM and choose "Postgres Config" under Server Setup 1. set password using alphanumeric characters. special characters can cause issues 2. install a postgres pg_hba.conf file (can be done in WHM or manually). md5 and plaintext passwords are both ok. Test by logging into cPanel and clicking on Postgres

3. 4. 5.


1 255.specifies how users should authenticate in order to access databases.tar </pre> . then create the database via cPanel along with users and user assignment.24 and earlier does not work and needs to be modified.conf file to find out how users should authenticate in order to access databases.255. First move the archive into /var/lib/pgsql and change its owner/group to user postgres. # su -l postgres # cd /var/lib/pgsql # pg_restore -v -C -O -d databasename -v databasename. How to Dump and Restore a Postgre SQL database Dump The following command is used to dump a postgres database.255.Configuration & Logs • • • /var/lib/pgsql/pgstartup.conf PostgreSQL? uses the /var/lib/pgsql/data/pb_hba.conf . but these are the only lines that the file needs to contain: local all all md5 host all all 127.log /var/lib/pgsql/data/pg_log/ /var/lib/pgsql/data/pb_hba.tar Restore Restore the databases as user postgres. You can start with the basic pg_hba.255 md5 Restart the PostgreSQL? service for the changes to take affect. What should it contain? The default pg_hba.0.0.conf file in cPanel 11. # pg_dump -Ft -b databasename > databasename.conf file and merely edit it. pb_hba.

Prevent Template1 from being edited by normal users Template1 is the template that all new databases are created from in postgres. run the following: # > > > > > psql -U postgres template1 -f . EOT . done Users cannot access phppgadmin Privileges are set up when a user first accesses the postgresql databases page in their cPanel. 3.Errors & Troubleshooting Will not start after new install 1. 2. REVOKE ALL ON SCHEMA public FROM public. To restrict template1 from being edited by normal users. phppgadmin is not going to work. If the user doesn't visit it. remove /var/lib/pgsql remove postgresql rpms /scripts/installpostgres Role does not exist Error appears in /usr/local/cpanel/logs/error_log as: ERROR: role "username" does not exist To add the role for all users: # cd /var/cpanel/users && for x in *. GRANT ALL ON SCHEMA public TO postgres.<< EOT REVOKE ALL ON DATABASE template1 FROM public. do su -c "createuser -S -D -R $x" postgres.

Restart server and use your new password to access PostgreSQL? Server.WHM version: WHM > SQL Services > Postgres Config For the superuser . UPDATE pg_database SET datistemplate = TRUE where datname = 'template1'. Resetting Passwords in PostGreSQL? For the superuser .conf Old Line: local all postgres password Change it to: local all postgres trust 2. Password has been updated.command line version Edit PostgreSQL? config file to establish a trust relationship to login without password: ◦ # vi /var/lib/pgsql/data/pg_hba. Change password: ◦ # psql -U postgres template1 -c alter user postgres with password ‘newpassword’. Revert back the original settings of config file: ◦ # vi /var/lib/pgsql/data/pg_hba. . drop database for regular users • http://docs. ◦ # service postgresql restart Source: http://linuxadminzone.Re-creating template1 if it happens to get written to psql -U postgres \c template1 UPDATE pg_database SET datallowconn = TRUE where datname = 'template0'. \c template1 UPDATE pg_database SET datallowconn = FALSE where datname = 'template0'. \c template0 UPDATE pg_database SET datistemplate = FALSE where datname = 'template1'.com/PostgreSQL_Reset_Password 1.conf Old Line: local all postgres trust Change it to: local all postgres password 5.planetargon. 4. create database template1 with template = template0. Restart PostgreSQL? Server: ◦ # service postgresql restart 3.

md5 should be used instead of trust. then you probably shouldn't. "In what context?" or any form of "No". Do not use trust as an authentication method. phpPgAdmin does not work reliably using the root override.conf and restarting PostgreSQL?. contrary to what several misguided posters have mentioned in our forums. trust equates to "Do you trust me?" If your answer is "Should I?". Many times I have fixed the problem without realizing it because my browser had cached a phpPgAdmin page.A couple of notes: • • For testing purposes. For some reason this application seems to be heavily cached most of the time. log into cPanel directly instead of using the root override. Clear your browser cache after editing pb_hba. • .