I have mysql/mysqli installed on my local machine via MacPorts and can access mysql/mysqli commands from the command line ONLY when using locahost.
If I try running:
mysql -u root -h 127.0.0.1 -p
I get the following error:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61)
When running:
mysql -u root -h localhost -p
Everything is fine.
The reason this bothers me is that I am trying to use mysqli_connect in a PHP script running on localhost. When I enter the host as localhost, it gives me this error:
Warning: mysqli_connect(): (HY000/2002): No such file or directory in ... on line 2 bool(false) Failed to connect to MySQL: No such file or directory
And when I enter the host as 127.0.0.1, I get a different error:
Warning: mysqli_connect(): (HY000/2002): Connection refused in /Users/raph/coding/webroot/rugapp/qbo-palmer/docs/partner_platform/example_app_ipp_v3/test.php on line 2 bool(false) Failed to connect to MySQL: Connection refused
It seems as though I have some configuration problems. What is the best way to fix them?