1

I've installed MySQL to my MacOSX 10.7.3.

It looks like MySQL is running:

Radeks-MacBook-Pro:htdocs radeksimko$ mysql5
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.61 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

I need to be able to access MySQL from PHP, so I tried to run sample file:

<?php
mysql_connect( "localhost", "user", "pass" );

but I've got this:

Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /usr/htdocs/index.php on line 4

I would set the mysql.default_socket in php.ini, but I'm really unable to find the socket file anywhere...

Where it should be placed/how could I find it? This found nothing:

Radeks-MacBook-Pro:~ radeksimko$ sudo find / -name mysql.sock 2>/dev/null
Radek Simko
  • 15,886
  • 17
  • 69
  • 107

2 Answers2

2

Try to replace the first parameter from "localhost" to "127.0.0.1". May be it will be help, I really don't know OSX.

(the mysql_connect() uses the mysql C library, and as I know that accepts both format: 127.0.0.1 and localhost - but when you use localhost, library uses the socket file, IP address uses TCP socket.)

airween
  • 6,203
  • 1
  • 14
  • 20