2012-02-28 141 views
1

我已經安裝了MySQL到我的MacOSX 10.7.3。MySQL在沒有套接字文件的情況下運行

它看起來像MySQL正在運行:

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> 

我需要能夠從PHP訪問MySQL,所以我試圖運行示例文件:

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

但我有這個:

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 

我會在php.ini中設置mysql.default_socket,但我真的無法找到任何地方的套接字文件...

它應該放在哪裏/我怎麼找到它? 此一無所獲:

Radeks-MacBook-Pro:~ radeksimko$ sudo find/-name mysql.sock 2>/dev/null 

回答

2

嘗試看看,從 「本地主機」 到 「127.0.0.1」 替換第一個參數。可能會有所幫助,我真的不知道OSX。 (mysql_connect()使用mysql C庫,並且據我所知接受格式:127.0.0.1和localhost - 但是當你使用本地主機時,庫使用套接字文件,IP地址使用TCP套接字。)

相關問題