I have created a website with Kohana PHP framework, version 3.1.3.1. The site is already running well in production. I just returned to it after a year and tried to setup local instance as I need to do some updates on that.
For some reason I keep getting following exception in browser:
Database_Exception [ 0 ]:
MODPATH/database/classes/kohana/database/mysql.php [ 67 ]
62 catch (ErrorException $e)
63 {
64 // No connection exists
65 $this->_connection = NULL;
66
67 throw new Database_Exception(':error',
68 array(':error' => mysql_error()),
69 mysql_errno());
70 }
71
72 // \xFF is a better delimiter, but the PHP driver uses underscore
MODPATH/database/classes/kohana/database/mysql.php [ 158 ] » Kohana_Database_MySQL->connect()
MODPATH/database/classes/kohana/database/mysql.php [ 347 ] » Kohana_Database_MySQL->query(arguments)
MODPATH/orm/classes/kohana/orm.php [ 1551 ] » Kohana_Database_MySQL->list_columns(arguments)
MODPATH/orm/classes/kohana/orm.php [ 439 ] » Kohana_ORM->list_columns(arguments)
MODPATH/orm/classes/kohana/orm.php [ 386 ] » Kohana_ORM->reload_columns()
MODPATH/orm/classes/kohana/orm.php [ 300 ] » Kohana_ORM->_initialize()
MODPATH/orm/classes/kohana/orm.php [ 109 ] » Kohana_ORM->__construct(arguments)
APPPATH/classes/controller/index.php [ 20 ] » Kohana_ORM::factory(arguments)
{PHP internal call} » Controller_Index->action_index()
SYSPATH/classes/kohana/request/client/internal.php [ 132 ] » ReflectionMethod->invokeArgs(arguments)
SYSPATH/classes/kohana/request.php [ 1129 ] » Kohana_Request_Client_Internal->execute(arguments)
DOCROOT/index.php [ 109 ] » Kohana_Request->execute()
There is no useful debug information attached. The connection to the database itself seems to work, as I do get specific exception while intentionally providing invalid credentials:
Database_Exception [ 1045 ]: Access denied for user 'root'@'localhost' (using password: YES)
this is the extract from "database.php"
'default' => array
(
'type' => 'mysql',
'connection' => array(
/**
* The following options are available for MySQL:
*
* string hostname server hostname, or socket
* string database database name
* string username database username
* string password database password
* boolean persistent use persistent connections?
*
* Ports and sockets may be appended to the hostname.
*/
'hostname' => '127.0.0.1',
'database' => 'databasename',
'username' => 'root',
'password' => '',
'persistent' => FALSE,
),
'table_prefix' => '',
'charset' => 'utf8',
'caching' => FALSE,
'profiling' => TRUE,
I found out that when I change 'database' key for some invalid string the exception stays the same. Is it possible the Kohana can connect to MySQL server but fails to access any database?
In order to test it, I tried to execute simple script using "mysqli", inside the Kohana app and var_dump some basic query results. It could connect to the database and listed all the tables though, so it seems there is something funny in the way kohana's ORM module is trying to communicate with database.
I used to get this working under Windows before (year ago..) and I cannot figure out what's wrong now, apart from the fact I switched to linux (using Ubuntu 14.04 now). I am using XAMP for linux (xampp-linux-x64-1.8.3-4-installer.run) to run apache, php and mysql.
Would appreciate any help!