烘焙模型 - CakePHP - Ubuntu

时间:2011-08-22 22:55:47

标签: php cakephp cakephp-appmodel cakephp-bake

我目前正在尝试为CakePHP中的项目烘焙模型。我已经设置了数据库表并烘焙了我的骨架项目。然后我通过终端执行以下命令:

cake bake -app /home/gary/glecto/

然后显示正确的菜单。当我选择“M”时,我收到以下错误

PHP Warning:  mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /usr/share/php/cake/libs/model/datasources/dbo/dbo_mysql.php on line 540

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /usr/share/php/cake/libs/model/datasources/dbo/dbo_mysql.php on line 540
PHP Warning:  mysql_select_db() expects parameter 2 to be resource, boolean given in /usr/share/php/cake/libs/model/datasources/dbo/dbo_mysql.php on line 546

Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /usr/share/php/cake/libs/model/datasources/dbo/dbo_mysql.php on line 546
PHP Warning:  mysql_get_server_info() expects parameter 1 to be resource, boolean given in /usr/share/php/cake/libs/model/datasources/dbo/dbo_mysql.php on line 554

Warning: mysql_get_server_info() expects parameter 1 to be resource, boolean given in /usr/share/php/cake/libs/model/datasources/dbo/dbo_mysql.php on line 554
PHP Warning:  mysql_query() expects parameter 2 to be resource, boolean given in /usr/share/php/cake/libs/model/datasources/dbo/dbo_mysql.php on line 588

Warning: mysql_query() expects parameter 2 to be resource, boolean given in /usr/share/php/cake/libs/model/datasources/dbo/dbo_mysql.php on line 588
Your database does not have any tables.

有没有人对如何解决这个问题有任何想法?我已经摸不着头几个小时了。

修改

连接代码

class DATABASE_CONFIG {

    var $default = array(
        'driver' => 'mysql',
        'persistent' => false,
        'host' => 'localhost',
        'port' => 3306,
        'login' => 'root',
        'password' => '',
        'database' => 'glectoMVC',
    );
}

另外 - 如果我查看cakePHP生成的启动页面,它确认我的数据库连接正常。

2 个答案:

答案 0 :(得分:2)

管理解决问题:

显然,CakePHP对localhost作为主机名并不满意。相反,我将其更改为127.0.0.1

答案 1 :(得分:0)

苏杜德。这看起来好像没有运行mysql。主要是因为它声明无法连接而不是凭据失败。你在运行什么LAMPP Stack?

如果所有其他方法都失败并且您正在使用的LAMPP应用程序状态正在成功运行,请确保您没有异步运行两个mysql实例。