Home > Backend Development > PHP Tutorial > 碰到个问题,用网上提供的方法都不好用,求教

碰到个问题,用网上提供的方法都不好用,求教

WBOY
Release: 2016-06-23 13:52:43
Original
831 people have browsed it

Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in


回复讨论(解决方案)

提供的信息太少

For some reason mysql on OS X gets the locations of the required socket file a bit wrong, but thanks to a veritable wizard I know (that's you, Gavin) the solution is as simple as setting up a symbolic link.

You may have a socket (appearing as a zero length file) as /tmp/mysql.sock or /var/mysql/mysql.sock but 1 or more apps is looking in the other location for it.

Rather than move the socket and have to edit config files and remember to keep edited files local and away from servers where the paths are correct, simply create a symbolic link so your mac finds the required socket, even when it's looking in the wrong place!

If you have /tmp/mysql.sock but no /var/mysql/mysql.sock then...

cd /var sudo mkdir mysqlsudo chmod 755 mysqlcd mysqlln -s /tmp/mysql.sock mysql.sock
Copy after login


If you have /var/mysql/mysql.sock but no /tmp/mysql.sock then

cd /tmpln -s /var/mysql/mysql.sock mysql.sock
Copy after login


You will need permissions to create the directory and link, so just prefix the commands above with sudo if necessary.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template