System information

Then run the following commands to create the asterisk user in the database and set
up permissions:
$ createuser -P
Enter name of user to add: asterisk
Enter password for new user:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new user be allowed to create databases? (y/n) y
Shall the new user be allowed to create more new users? (y/n) n
CREATE ROLE
Now, edit the pg_hba.conf file in order to allow the asterisk user you just created to
connect to the PostgreSQL server over the TCP/IP socket.
On CentOS, this file will be located at /var/lib/pgsql/data/pg_hba.conf. On Ubuntu, you
will find it at /etc/postgresql/8.4/main/pg_hba.conf.
At the end of the file, replace everything below this line:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
with the following:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
host all asterisk 127.0.0.1/32 md5
local all asterisk trust
Configuring PostgreSQL Database Access via IPv6 localhost
Also, on Ubuntu you will likely need to add the following line:
host all asterisk ::1/128 md5
Without it, when you get to “Validating the ODBC Connector” on page 351 you may
end up with the following error when connecting:
[28000][unixODBC]FATAL: no pg_hba.conf entry for host "::1", user "asterisk",
database "asterisk", SSL off
[ISQL]ERROR: Could not SQLConnect
Now you can create the database that we will use throughout this chapter. Call the
database asterisk and set the owner to your asterisk user:
$ createdb --owner=asterisk asterisk
CREATE DATABASE
You can set the password for the asterisk user like so:
$ psql -d template1
template1=# "ALTER USER asterisk WITH PASSWORD 'password'"
template1=# \q
Exit from the postgres user:
$ exit
344 | Chapter 16:Relational Database Integration