我已经创建了一个网站Kohana PHP框架,版本3.1.3.1。该站点已经在生产中运行良好。我一年后才回到它,并试图设置本地实例,因为我需要做一些更新。
由于某些原因,我一直在浏览器中得到以下异常:
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()
没有附加有用的调试信息。到数据库本身的连接似乎正常,因为我在故意提供无效凭据时确实得到了特定的异常:
Database_Exception [ 1045 ]: Access denied for user 'root'@'localhost' (using password: YES)
这是从"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,
我发现,当我改变'数据库'键的一些无效字符串的例外保持不变。是否有可能Kohana可以连接到MySQL服务器,但无法访问任何数据库?
为了测试它,我尝试使用"mysqli"执行简单的脚本,在Kohana应用程序和var_dump一些基本的查询结果。它可以连接到数据库并列出所有表,所以看起来kohana的ORM模块试图与数据库通信的方式有些有趣。
我以前在Windows下(一年前…)我不知道现在出了什么问题,除了我切换到linux(现在使用Ubuntu 14.04)。我使用XAMP for linux (XAMP -linux-x64-1.8.3-4-installer.run)来运行apache, php和mysql。
感谢您的帮助!
如果您的root
帐户没有密码,正确的语法是
'password' => FALSE,