3

我目前正在尝试为 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 生成的启动页面,它确认我的数据库连接正常。

4

2 回答 2

2

Managed to figure it out:

Apparently CakePHP isn't too happy with localhost as a host name. Instead I changed it to 127.0.0.1

于 2011-08-23T12:29:28.820 回答
0

伙计。这看起来像 mysql 没有运行。主要是因为它说明无法连接而不是凭据失败。您正在运行什么 LAMPP 堆栈?

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

于 2011-08-23T11:05:47.087 回答