Friday, 22 January 2010

Not being able to create postgresql database even after the postgresql package is installed

Recently with a cPanel server, we had this issue of not being able to create postgresql database even after the postgresql package is installed and database server is running. Fixing of one issue lead to another there by needing to fix all the errors.
Cpanel::AdminBin::adminrun(postgres) set error in context postgres
[2010-01-16 12:24:18 -0500] warn [postgres::listdbs] Encountered error in postgres::listdbs: Error from postgres wrapper: PostgreSQL has not been configured by the administrator. Unable to locate pgpass file.

This was fixed by doing these,

Login to WHM => SQL Services => Postgres Config => Click on “Install Config”.
Login to WHM => SQL Services => Postgres Config => “Set a Postgresql password also”


No error in cPanel after doing above. However that followed by an issue of created DBs not being appeared in the List DB page of Postgresql databases. Went to shell. Logged in as root . Switched to postgres. “su – postgres” . Ran the command “psql” and then

-bash-3.2$ psql
Welcome to psql 8.1.18, the PostgreSQL interactive terminal.


Type: copyright for distribution terms
h for help with SQL commands
? for help with psql commands
g or terminate with semicolon to execute query
q to quit

postgres=# l
List of databases
Name | Owner | Encoding
-----------+----------+----------
postgres | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8
(3 rows)



postgres=# q

No DB was created. Checked the logs /usr/local/cpanel/logs/error_log and it had entries likeERROR: role “username” does not exist which meant, no roles to create the database.

cd /var/cpanel/users && for x in *; do su -c "createuser -S -D -R $x" postgres; done

No comments:

Post a Comment