Skip to content

Instantly share code, notes, and snippets.

@asika32764
Last active January 28, 2021 21:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save asika32764/6760580 to your computer and use it in GitHub Desktop.
Save asika32764/6760580 to your computer and use it in GitHub Desktop.
Using this command to create a symbol link to mysql.sock in Mac

If run mysql_connect() in php cli and return this error:

PHP Warning:  mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in Command line code on line 1PHP Warning:  mysql_connect(): No such file or directory in Command line code on line 1

Using this command to create a symbol link to mysql.sock in Mac

# XAMPP
sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock /var/mysql/mysql.sock
# MAMP
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
# AMPPS
sudo ln -s /Applications/AMPPS/mysql/tmp/mysql.sock /var/mysql/mysql.sock
@nahumnp
Copy link

nahumnp commented Jun 1, 2018

In my case.
sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock /tmp/mysql.sock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment