0

My cakephp database setup looks like this:

array(
        'datasource' => 'Database/Mysql',
        'persistent' => false,
        'host' => '127.0.0.1',
        'login' => 'dbUser',
        'password' => '*********',
        'database' => '*********',
        'prefix' => '',
        //'encoding' => 'utf8',
    );

I can connect to local mysql using the same host, user and password on the command line:

mysql -u dbUser -p -h 127.0.0.1

No problem. I can the USE the same database on the command line, call SELECT using the same user on the mysql cli.

BUT cakephp keeps giving me the error 111. Why?

I installed mysql 5.6 on Ubuntu 14.04:

apt-get install mysql-server-5.6 mysql-client-5.6 mysql-common-5.6 

And phpinfo() shows that PDO and PDO_mysql is installed: PDO

PDO support enabled
PDO drivers mysql

pdo_mysql

PDO Driver for MySQL    enabled
Client API version  5.5.47

Directive   Local Value Master Value
pdo_mysql.default_socket    /var/run/mysqld/mysqld.sock /var/run/mysqld/mysqld.sock

The error cakephp gives me is this:

 Error: [MissingConnectionException] Database connection "Mysql" is missing, or could not be created.
Exception Attributes: array (
  'class' => 'Mysql',
  'message' => 'SQLSTATE[HY000] [2003] Can\'t connect to MySQL server on \'127.0.0.1\' (111)',
  'enabled' => true,
)

What am I missing? I have set up at least 10 other cakephp servers, and many of them run on mysql 5.6 using the same PDO driver version - the setups look the same, but I must be missing something.

Francois Stark
  • 153
  • 2
  • 10
  • Try localhost instead of 127.0.0.1 – JazzCat Apr 09 '16 at 11:55
  • Kindly check this one http://stackoverflow.com/questions/19280245/cakephp-database-connection-mysql-is-missing-or-could-not-be-created It will surly help you. – Kritik Apr 10 '16 at 12:55
  • JazzCat - I just tried localhost. It does a "hosts" lookup and gives exactly the same error: Can\'t connect to MySQL server on \'127.0.0.1\' (111)' – Francois Stark Apr 11 '16 at 04:09
  • Problem solved using [this helpful code](http://php.net/manual/en/pdo.connections.php). It showed me that I was actually using another database definition, and once I actually started using the block shown in the question, the problem went away. – Francois Stark Apr 11 '16 at 05:22

0 Answers0