title: How to connect CakePHP to a Postgres database?
body: <p>I'm just starting with CakePHP, I went through the blog tutorial without trouble but would now like to try it with a proper DBMS like postgres. I tweaked the database.php file to point to a database I created in my local postgres instance: </p>
  
  <pre><code>class DATABASE_CONFIG {
  
      public $default = array(
          'datasource' =&gt; 'Database/Postgres',
          'persistent' =&gt; false,
          'host' =&gt; 'localhost',
          'port' =&gt; '5432',
          'login' =&gt; 'cakephp',
          'password' =&gt; 'cakephp',
          'database' =&gt; 'cakephp',
          'schema' =&gt; 'blog_tuto',
          'prefix' =&gt; '',
          //'encoding' =&gt; 'utf8',
      );
  
      public $test = array(
          'datasource' =&gt; 'Database/Postgres',
          'persistent' =&gt; false,
          'host' =&gt; 'localhost',
          'port' =&gt; '5432',
          'login' =&gt; 'cakephp',
          'password' =&gt; 'cakephp',
          'database' =&gt; 'cakephp',
          'schema' =&gt; 'blog_tuto',
          'prefix' =&gt; '',
          //'encoding' =&gt; 'utf8',
      );
  }
  </code></pre>
  
  <p>I have no issues connecting to this database with a SQL client, but CakePHP complains with the following message:</p>
  
  <pre><code>CakePHP is NOT able to connect to the database.
  
  Database connection "Postgres" is missing, or could not be created.
  Selected driver is not enabled
  </code></pre>
  
  <p>I already verified that the postgres DboSource class in present. The postgres php module is also installed:</p>
  
  <pre><code>$ php -m | grep pg
  pdo_pgsql
  pgsql 
  </code></pre>
  
  <p>What am I missing? Thanks.</p>
  
  <p><strong>Update I</strong> : The output of phpinfo related to Postgres goes below:</p>
  
  <pre><code>pdo_pgsql
  PDO Driver for PostgreSQL   enabled
  PostgreSQL(libpq) Version   9.1.9
  Module version  1.0.2
  Revision    $Id: pdo_pgsql.c 321634 2012-01-01 13:15:04Z felipe $
  
  pgsql
  PostgreSQL Support  enabled
  PostgreSQL(libpq) Version   9.1.9
  Multibyte character support     enabled
  SSL support     enabled
  Active Persistent Links     0
  Active Links    0
  
  Directive   Local Value Master Value
  pgsql.allow_persistent  On  On
  pgsql.auto_reset_persistent Off Off
  pgsql.ignore_notice Off Off
  pgsql.log_notice    Off Off
  pgsql.max_links Unlimited   Unlimited
  pgsql.max_persistent    Unlimited   Unlimited
  </code></pre>
  
  <p><strong>Update II</strong> : When I accessed the application today trying to follow <a href="https://stackoverflow.com/questions/20948599/how-to-connect-cakephp-to-a-postgres-database#comment42869042_27106796">Ajir's suggestion</a> I surprisingly got a different error message: "Authentication failed" - meaning that CakePHP is now able to connect. I installed Postgres 9.3 some months ago and had not re-created the tutorial objects; all I needed to do was run the SQL script and the tutorial application is now fully functional.</p>
  
  <p>Whatever is wrong is likely restricted to Postgres 9.1. </p>