dpgbh20688 2014-12-17 18:34
浏览 35

openshift没有工作数据库连接

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...

  • 写回答

1条回答 默认 最新

  • duanaoou4105 2014-12-18 19:01
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路