Let's start with a brief introduction.
[ Note 1] Installation path for MySQL under Mac:
/usr/local/mysql-5.1.63-osx10.6-x86_64
The data file of the database is in the folder of the directory;
The command file is in the Bin folder.
[ Note 2] The method of opening the MySQL command line via terminal:
/usr/local/mysql-5.1.63-osx10.6-x86_64
Okay, here's the solution to the wrong answer to the MySQL database.
1, first determine the problem is mysql_connect () and Mysql_pconnect (), the fault phenomenon is that the function returns NULL, and Mysql_error () returns "No such file or directory"
2, write a phpinfo page, find Mysql.default_socket, Mysqli.default_socket, Pdo_mysql.default_socket
3, start MySQL (see note 2), execute command STATUS; Note the value of the UNIX socket
4, if the values of 2 and 3 are different, open php.ini (you can find the location of php.ini from the Phpinfo page, which is/private/etc/php.ini by default), and change the value of the three configuration items mentioned in 2 to a value of 3.
(Note that the three places were modified: Mysql.default_socket, Mysqli.default_socket, Pdo_mysql.default_socket)
5, restart Apache
Mac PHP connection mysql error "No such file or directory" solution