I'm experiencing issues connecting to mysql in the Openshift platform. I have this site http://studentinfobook-rrubio.rhcloud.com/showing errors. It's a cakephp very simple app, that apparently can't connect to mysql cartridge. But if i attempt connect directly to mysql in the command line like:
mysql --user=user_name --password=your_password db_name
then it's connecting very well. The same connecting w/ phpmyadmin. Do you think it's something w/ cakephp (this app is working locally), or something i still have to do in openshift?
Thanks in advance...
EDIT
There is not too much code to be written. This is my database.php file in [/var/lib/openshift/548f654a4382ec3b58000078/app-root/repo/app/Config]:
<?php
define('DB_HOST', getenv('OPENSHIFT_MYSQL_DB_HOST'));
define('DB_PORT', getenv('OPENSHIFT_MYSQL_DB_PORT'));
define('DB_USER', getenv('OPENSHIFT_MYSQL_DB_USERNAME'));
define('DB_PASS', getenv('OPENSHIFT_MYSQL_DB_PASSWORD'));
define('DB_NAME', getenv('OPENSHIFT_GEAR_NAME'));
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => DB_HOST,
'port' => DB_PORT,
'login' => DB_USER,
'password' => DB_PASS,
'database' => DB_NAME,
'prefix' => ''
//'encoding' => 'utf8',
);
As i said this returns from mysql the error:
SQLSTATE[HY000] [2002] No such file or directory
But perfectly worked when connecting from the command line or phpmyadmin with the supplied credentials...
That error message usually seems to mean that the socket is not available to use for connecting to the mysql server. Are you using a scaled application? if so, then there is no socket to use since the mysql database is on another gear. Here is a sample connection file from a cakephp-example that runs on openshift currently: https://github.com/openshift/cakephp-example/blob/master/php/app/Config/database.php
You can see if that helps you with your issue.