An error message with cakephp inline - Missing Database Connection

Geetix

I have done my website normally in localhost with wamp, and it came the moment to upload it inline.

I've used Cakephp 2, with the security component that block all the website. So I have to login me, before to go directly in the application. I've uploaded my data base into phpmyadmin on my web server (OVH - Perso offer, so no ssh available). I've configured the database.php file with my database informations. It is well those one, I'm sure, because it's the same like my main website (because this application is into a folder at the root of my site itself developed with Cakephp).

At a glance, when I try to access to my site, I've this error message, and I don't know why .. :

Missing Database Connection
Error: A Database connection using "Mysql" was missing or unable to connect.    
The database server returned this error: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' (2)

Notice: If you want to customize this error message, create app/View/Errors/missing_connection.ctp

Stack Trace
CORE/Cake/Model/Datasource/DboSource.php line 260 → Mysql->connect()
CORE/Cake/Model/ConnectionManager.php line 105 → DboSource->__construct(array)
CORE/Cake/Model/Model.php line 3482 → ConnectionManager::getDataSource(string)
CORE/Cake/Model/Model.php line 1128 → Model->setDataSource(string)
CORE/Cake/Model/Model.php line 3504 → Model->setSource(string)
CORE/Cake/Model/Model.php line 1357 → Model->getDataSource()
CORE/Cake/View/Helper/FormHelper.php line 215 → Model->schema()
CORE/Cake/View/Helper/FormHelper.php line 468 → FormHelper->_introspectModel(string, string)
APP/View/Layouts/login.ctp line 30 → FormHelper->create(string)
CORE/Cake/View/View.php line 948 → include(string)
CORE/Cake/View/View.php line 910 → View->_evaluate(string, array)
CORE/Cake/View/View.php line 542 → View->_render(string)
CORE/Cake/View/View.php line 479 → View->renderLayout(string, string)
CORE/Cake/Controller/Controller.php line 954 → View->render(null, null)
CORE/Cake/Routing/Dispatcher.php line 198 → Controller->render()
CORE/Cake/Routing/Dispatcher.php line 165 → Dispatcher->_invoke(UsersController, CakeRequest)
APP/webroot/index.php line 108 → Dispatcher->dispatch(CakeRequest, CakeResponse)

My database.php file :

class DATABASE_CONFIG {

  public $default = array(
      'datasource' => 'Database/Mysql',
      'persistent' => false,
      'host' => 'localhost',
      'login' => 'root',
      'password' => '',
      'database' => 'prolity',
      'prefix' => '',
      //'encoding' => 'utf8',
  );

  public $ovh = array(
      'datasource' => 'Database/Mysql',
      'persistent' => false,
      'host' => '***',
      'login' => '***',
      'password' => '***',
      'database' => '***',
      'prefix' => '',
      'encoding' => 'utf8',
  );
}

I use just $ovh, and it's well selected in bootstrap.php. I even tried to put

'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock'

But it's the same thing.

I have all audited, and all seems correct. Google didn't help me really well, and I'm turning to you because I don't have any other ideas.

I can give you the link inline, but I think it's not really necessary.

Thanks for you're help,

Etix.

Nunser

The problem was that the declaration to use another database was not in the correct place. The OP was using this line in bootstrap.php

Cache::config('default', array('engine' => 'File'));

to try to change the database used. That line is used for cache files, so it has no power over database settings. To tell the models to use another database (other than default), you need to change the model attribute and do

class Example extends AppModel {
    public $useDbConfig = 'ovh';
}

That just applies for one model, but if you want to do it for the whole app, you can add that line to AppModel

class AppModel extends Model{
    public $useDbConfig = 'ovh';
}

(and of course, not overwrite it in the other models).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Missing Plugin error in Cakephp

From Dev

Error database connection is missing while using cae bake

From Dev

Error message when I test the connection of a database using PowerBuilder

From Dev

Error message when I test the connection of a database using PowerBuilder

From Dev

Multiple database connection in cakephp 3

From Dev

React error message missing

From Dev

React error message missing

From Dev

Strange CakePHP message: View file is missing

From Dev

ExecuteReader: Connection error message

From Dev

SQL Connection Error Message

From Dev

CakePHP and XAMPP error on PDO connection

From Dev

CakePHP and XAMPP error on PDO connection

From Dev

cakephp error. Connection to database ...not ...: Access denied for user 'my_app'@'localhost' (using password: YES)

From Dev

cakephp error. Connection to database ...not ...: Access denied for user 'my_app'@'localhost' (using password: YES)

From Dev

Moodle database connection error

From Dev

Weird error on connection with database

From Dev

Eclipse error database connection

From Dev

error in PHP and database connection

From Dev

Weird error on connection with database

From Dev

Error establishing in database connection

From Dev

connection error with Sqlite database

From Dev

Connection error to database in cloud

From Dev

Mysql Database error connection

From Dev

Error in configuring cakephp without database

From Dev

Error message in restoring database

From Dev

MySQL connection error without message

From Dev

SSH connection refused/error message

From Dev

CakePHP 3: Missing route error for route that exists

From Dev

cakephp - redirecting unauthenticated user on "Missing method" error

Related Related

HotTag

Archive