A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearHow do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX? - page 1
User InfoPosts
How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#1
I am currently reading "Beginning CakePHP:From Novice to Professional" by David Golding. At one point I have to use the CLI-command "cake bake", I get the welcome-screen but when I try to bake e.g. a Controller I get the following error messages:

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 117

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 122

Warning: mysql_get_server_info(): supplied argument is not a valid MySQL-Link resource in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 130

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 154
Error: Your database does not have any tables.


I suspect that the error-messages has to do with php trying to access the wrong mysql-socket, namely the default osx mysql-socket - instead of the one that MAMP uses. Hence I change my database configurations to connect to the UNIX mysql-socket (:/Applications/MAMP/tmp/mysql/mysql.sock):

class DATABASE_CONFIG {

var $default = array(
'driver' => 'mysql',
'connect' => 'mysql_connect',
'persistent' => false,
'host' =>':/Applications/MAMP/tmp/mysql/mysql.sock', // UNIX MySQL-socket
'login' => 'my_user',
'password' => 'my_pass',
'database' => 'blog',
'prefix' => '',
);

}


But I get the same error-messages with the new socket:

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock:3306' (2) in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 117

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 122

Warning: mysql_get_server_info(): supplied argument is not a valid MySQL-Link resource in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 130

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /Applications/MAMP/htdocs/blog/cake/libs/model/datasources/dbo/dbo_mysql.php on line 154
Error: Your database does not have any tables.


Also, even though I use the UNIX-socket that MAMP show on it's welcome-screen, CakePHP loses the database-connection, when using this socket instead of localhost.

Any ideas on how I can get bake to work?

-- Edit 1 --

Thank you guys for helping me out! :)

I have a problem figuring out where in my.cnf to edit to get MySQL to listen to TCP/IP request. The only paragraph I can find where TCP/IP is mentioned is the following:

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking


That allows me to turn off TCP/IP completely, which is the opposite of my intention. I don't know how to go about what you suggest, if you could be more elaborate it would be great. I am a total n00b on these matters :S

Reg. connecting to a local socket: I removed the leading colon in the host-parameter, same result.

posted date: 2008-12-14 05:29:00


Re: How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-14 05:29:01


Re: How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#3
From the error, it looks like it's trying to connect to an actual IP address and not a UNIX socket, look: '/Applications/MAMP/tmp/mysql/mysql.sock:3306'It's appending a port to the socket, which is wrong.So, I'd first try to configure MySQL to listen to TCP/IP requests (edit the proper section in my.cnf) and try providing 127.0.0.1 instead of the socket.In case you won't scroll down:To fix it at CakePHP level, change host on database.php to 'localhost' and add a port directive with its value set to the socket name '/Applications/MAMP/tmp/mysql/mysql.sock'

posted date: 2008-12-14 05:37:00


Re: How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#4
Yeah had a similar issue, I think pointing to the the socket:portno as Vinko suggested might work - however if you use an ip address / localhost you'll be fine.

posted date: 2008-12-14 09:19:00


Re: How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#5
I had the same problem, when using MAMP and the Cake CLI. I'm running CakePHP 1.1xxx and MAMP 1.7.The problem is, that the MySQL socket can't be found :DOpen Terminal and enter the following:my-macbook:~ chris$ php -i | grep mysql.default_socketmysql.default_socket => no value => no valuemy-macbook:~ chris$ php -i -c /Applications/MAMP/conf/php5 | grep mysql.default_socketmysql.default_socket => /Applications/MAMP/tmp/mysql/mysql.sock => /Applications/MAMP/tmp/mysql/mysql.sockThe catch is that without explicitly giving the php binary the path to its (read MAMP's) config file, the mysql.default_socket is not set.Using that I did not need to change my database configuration whatsoever.

posted date: 2008-12-16 18:37:00


Re: How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#6
class DATABASE_CONFIG{public $default = array('driver' => 'mysql','persistent' => false,'host' => 'localhost','login' => 'account','password' => 'password','database' => 'database','prefix' => '','port'=>'/var/mysql/mysql.sock');}

posted date: 2009-01-02 09:52:00


Re: How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#7
This worked for me:class DATABASE_CONFIG{ public $default = array( 'driver' => 'mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'account', 'password' => 'password', 'database' => 'database', 'prefix' => '', 'port' => '/Applications/MAMP/tmp/mysql/mysql.sock' );}

posted date: 2009-03-05 20:42:00


Re: How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#8
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sockI had this exact same problem with mamp, and fixed it with the above command. I think you have to run this command every time you restart your computer. Maybe there is a better way to do it, but I use this with clix.app, so it is usually pretty fast. Also, change your host to localhost.

posted date: 2009-03-13 06:32:00


Re: How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#9
Try configuring your firewall... That was the case for me!

posted date: 2009-08-10 00:38:00


Re: How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#10
I find the solution to this problem : Add a socket config in the cakephp app/config/database.php fileclass DATABASE_CONFIG {var $default = array('driver' => 'mysql','persistent' => false,'host' => 'localhost','port' => '/Applications/MAMP/tmp/mysql/mysql.sock', // here is the key !'login' => 'you','password' => 'yourpass','database' => 'yourdb','prefix' => '',);

posted date: 2009-08-23 08:22:00


Re: How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#11
You can also make a symbolic link, bake is looking for mysql.sock in /tmplike this:ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sockCheers, Ebbot.

posted date: 2009-09-21 02:40:00


Re: How do I get CakePHP bake to find mysql.sock and recognize MySQL while using MAMP on Mac OSX?#12
This was the real answer. Thank you Julien.

posted date: 2010-03-17 21:08:00


select page: « 1 2 »
Copyright ©2008-2017 www.momige.com, all rights reserved.