Question

I am currently trying to bake models for a project in CakePHP. I have set up my database tables and baked my skeleton project. I then execute the following via terminal:

cake bake -app /home/gary/glecto/

Which then display's me the correct menu. When I choose "M" I get the following error

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.

Does anyone have any ideas on how I could solve this? I've been scratching my head for hours.

EDIT

Connection code

class DATABASE_CONFIG {

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

Also - If I look at the cakePHP generated startup page it confirms that my database connection is OK.

Was it helpful?

Solution

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

OTHER TIPS

Sup dude. this does look like mysql isn't running. Mainly as it's stating a can't connect and not a credentials fail. What LAMPP Stack are you running?

If all else fails and the LAMPP app you're using states the process is running successfully, ensure you haven't two instances of mysql running asynchronously.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top